File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JFileChooser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFileChooser" Watch "JFileChooser" New topic


Jude Fawly
Ranch Hand

Joined: Dec 01, 2004
Posts: 33

how can i limit the jfilechooser to search only in a specific folder nothing more?


Teach me to die that so I may<br />Rise glorious at the awful day
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
you can hide/disable the navigation buttons and the combobox, but subfolders
will show.

might be easier to use a JList populated with listFiles() filtered by isFile()
Paul Clapham

Joined: Oct 14, 2005
Posts: 19858

Have you tried providing it with a FileFilter that only accepts files (not subdirectories) in that directory?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Hi Doc,

yep, that works - didn't even cross my mind (a short trip!)
I agree. Here's the link:
subject: JFileChooser
It's not a secret anymore!