I'm trying to use JFilechooser to select a directory. I'm using the method getCurrentDirectory(). However, jfilechooser seems to only return the directory when i select a file first. Can anybody tell me how i can return the directory without first selecting a file?
Pete<br />"Reality is an illusion <br />brought on by a lack of <br />drink, drugs and smut"
posted 15 years ago
Use the getSelectedFile method instead. It will return a directory if that is what is selected. You can also use setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) to ensure that only directories may be selected.