Two Laptop Bag*
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
Author

Directory Chooser Dialog?

shakila
Greenhorn

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

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

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

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

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!
Shakila
 
Consider Paul's rocket mass heater.
 
subject: Directory Chooser Dialog?
 
Similar Threads
DirectoryChooser - How?
Directory Chooser on JSF
bizar JFileChooser error after connection refused to localhost
problem with file chooser
JFileChooser Last Path