jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes Directory Chooser Dialog? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Directory Chooser Dialog?" Watch "Directory Chooser Dialog?" New topic

Directory Chooser Dialog?


Joined: Aug 02, 2000
Posts: 9
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.
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
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.

Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
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,

Joined: Aug 02, 2000
Posts: 9
Hi Manfred,
Thanks for the reply. I solved the problem by setting the FileSelectionMode to DIRECTORIES_ONLY. Thanks again!
I agree. Here's the link: http://aspose.com/file-tools
subject: Directory Chooser Dialog?
It's not a secret anymore!