Hi, I have a Java application that reads in and manipulates a few files. I assume the files are in the default directory without asking the user. I would like to make that better and ask the user where he has the files he wants read. I know you can select files using the File Chooser Dialog but I was wondering if there was a way to bring up a similar dialog to choose directories instead of specific files. Thanks, Shakila
"shakila", The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements. Thanks.
Hi, No there is not any canned dialog to perform the directory. But, all is not lost... Swing developer have left the door open on the JFileChooser so that we can make it into a directory chooser. According to the JFileChooser API if you create a class that extends FileFilter you can then override the methods accept and getDescription which controls the display of JFileChooser. The code below shows how to override the FileFilter and use it in some method.
Good Luck, Manfred.
Joined: Aug 02, 2000
Hi Manfred, Thanks for the reply. I solved the problem by setting the FileSelectionMode to DIRECTORIES_ONLY. Thanks again! Shakila