A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Swing / AWT / SWT
Filter in JFileChooser
Joined: Aug 02, 2005
Jan 20, 2006 17:40:00
How can i say that my
shows only the files with .red extension?
There is a method accept() in API but i dont know how to accept only .red files.
Thanks in advance
Joined: Aug 30, 2005
Jan 23, 2006 14:21:00
Basically you have to create an instance of the class
, then call JFileChooser.addChoosableFileFilter().
You will also want to remove the "accept all" file filter. This is the basic idea:
JFileChooser my_chooser = new JFileChooser(); FileFilter my_filter = new MyFileFilter(); my_chooser.removeChoosableFileFilter(my_chooser.getAcceptAllFileFilter()); my_chooser.addChoosableFileFilter(my_filter);
There is a tutorial here:
It is sorta covered in the
JavaRanch Style Guide
subject: Filter in JFileChooser
Force content type
Jfilechooser saving files with file extension
Only accept a file type in JFileChooser ?
disabling the view of files in Jtree
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013