Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Filter in JFileChooser  RSS feed

 
Kudret Serin
Ranch Hand
Posts: 167
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:


There is a tutorial here:

http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!