aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JFileChooser  extension list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JFileChooser  extension list" Watch "JFileChooser  extension list" New topic
Author

JFileChooser extension list

osgaldor Storm
Greenhorn

Joined: Feb 28, 2013
Posts: 7
I'm creating a simple text editor in Java, I want to be able to allow the user to select the type of file to open or save in the JFileChooser, I don't know how to set the FileFilter to allow multple types. Can anyone point me in the right direction? Right now I can only get it to choose either text files ".txt" or all files. I want to be able to save as .html, .php, .rb. etc. I have googled the JFileChooser filefilter and can't seem to find an example or how to. Can you help?
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2176
    
    7
What's wrong with the example from the API?
osgaldor Storm
Greenhorn

Joined: Feb 28, 2013
Posts: 7
It doesn't address my question.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You mean because it only tells you how to write a file chooser for .jpg and .gif files, and those weren't the extensions you wanted? Surely you could adapt it to your needs.
osgaldor Storm
Greenhorn

Joined: Feb 28, 2013
Posts: 7
Okay. Thank you. I have found the solution to my problem.
osgaldor Storm
Greenhorn

Joined: Feb 28, 2013
Posts: 7
Well, no, I meant because it didn't show how to use completely different types. Gifs and Jpegs are image files.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10266
    
    8

So you got it working or not? In case you didn't, check out http://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html#filters


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JFileChooser extension list