JFilerChooser default filefilter

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2006
Posts: 162
Reputation: Cerberus is an unknown quantity at this point 
Solved Threads: 14
Cerberus Cerberus is offline Offline
Junior Poster

JFilerChooser default filefilter

 
0
  #1
Mar 24th, 2007
Hi, does anyone know how to set a JFileChoosers default filter back to accept all files after custom filters have been added?

Thanks.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: JFilerChooser default filefilter

 
0
  #2
Mar 24th, 2007
Surely it would be something on the lines of changing the *.txt filter back to "*."

Although that's just me thinking out aloud.
Last edited by iamthwee; Mar 24th, 2007 at 12:15 pm.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 162
Reputation: Cerberus is an unknown quantity at this point 
Solved Threads: 14
Cerberus Cerberus is offline Offline
Junior Poster

Re: JFilerChooser default filefilter

 
0
  #3
Mar 24th, 2007
JFileChooser has a setFileFilter(FileFilter filter) method. I could call this by putting any of my custom filters in but i don't have an identifier for the default one. So basically i'm just wonding what the default identifier is.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: JFilerChooser default filefilter

 
0
  #4
Mar 24th, 2007
Well surely the default filter must be *.*.

Which I would imagine was derived from a regular expression? But I don't have my java compiler at hand to test that. And the API for JFilterChooser may not include that.
Last edited by iamthwee; Mar 24th, 2007 at 12:52 pm.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 162
Reputation: Cerberus is an unknown quantity at this point 
Solved Threads: 14
Cerberus Cerberus is offline Offline
Junior Poster

Re: JFilerChooser default filefilter

 
0
  #5
Mar 24th, 2007
but the setFileFilter method requires a FileFilter identifier not a String.

for example:

ExtensionFileFilter filter = new ExtensionFileFilter(text, "*.txt");
fileChooser.addChooseableFileFilter(filter);
chooser.setFileFilter(filter);

perhaps i'm misunderstanding.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,266
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: JFilerChooser default filefilter

 
0
  #6
Mar 24th, 2007
http://www.particle.kth.se/~lindsey/...9/chooser.html

import javax.swing.*;
import java.io.*;

/** Filter to work with JFileChooser to select java file types. **/
public class JavaFilter extends javax.swing.filechooser.FileFilter
{
  public boolean accept (File f) {
    return f.getName ().toLowerCase ().endsWith ("*.*")
          || f.isDirectory ();
  }
  
  public String getDescription () {
    return "Java files (*.*)";
  }
} // class JavaFilter

Perhaps? Untested. Although I'd imagine it to be something along those lines?
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 162
Reputation: Cerberus is an unknown quantity at this point 
Solved Threads: 14
Cerberus Cerberus is offline Offline
Junior Poster

Re: JFilerChooser default filefilter

 
0
  #7
Mar 24th, 2007
Ok thanks i'll take a look at the example.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,217
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 489
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is online now Online
Code tags enforcer

Re: JFilerChooser default filefilter

 
0
  #8
Mar 24th, 2007
Originally Posted by iamthwee View Post
http://www.particle.kth.se/~lindsey/...9/chooser.html
very interesting website...
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC