Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Directory Chooser Dialog?

 
shakila
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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.
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manfred,
Thanks for the reply. I solved the problem by setting the FileSelectionMode to DIRECTORIES_ONLY. Thanks again!
Shakila
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic