i have added an instance of directory dialog which browses folder in the addSelectionListener of btnBrowse and then added the returned path to the text field,also i've added GUIManager.getDefault.setChosenPath(dir) to save the returned path in GUIManager,but the exception appears when any other button "exit,cancel or ok is pressed"