Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
paul wheaton
Ron McLeod
Devaka Cooray
Sheriffs:
Jeanne Boyarsky
Liutauras Vilda
Paul Clapham
Saloon Keepers:
Tim Holloway
Carey Brown
Piet Souris
Bartenders:
Forum:
Swing / AWT / SWT
Filter in JFileChooser
Kudret Serin
Ranch Hand
Posts: 167
I like...
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi all,
How can i say that my JFileChooser 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
Ed Ewing
Greenhorn
Posts: 29
posted 19 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Basically you have to create an instance of the class FileFilter, 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:
http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Jfilechooser saving files with file extension
Only accept a file type in JFileChooser ?
Force content type
disabling the view of files in Jtree
JFileChooser
More...