|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.filechooser.FileFilter
uk.ac.starlink.util.gui.BasicFileFilter
public class BasicFileFilter
A FileFilter for configuring a JFileChooser
to only show
files that have one of a set of file extensions. Also implements
FilenameFilter to provide similar services for filtering directory
contents using the File
class (see File.listFiles
.
Example - create filters for HDS and FITS files and use with a BasicFileChooser.
BasicFileChooser chooser = new BasicFileChooser(); BasicFileFilter fitsFilter = new BasicFileFilter( new String{ "fit", "fits" }, "FITS files" ) chooser.addChoosableFileFilter( fitsFilter ); BasicFileFilter hdsFilter = new BasicFileFilter( "hds", "HDS container files" ); chooser.addChoosableFileFilter( hdsFilter ); chooser.showOpenDialog( this );Example - filter the files in a directory.
BasicFileFilter idsFilter = new BasicFileFilter( "ids" ); File dir = new File( "." ); File[] files = dir.listFiles( idsFilter );
Constructor Summary | |
---|---|
BasicFileFilter()
Creates a file filter. |
|
BasicFileFilter(String extension)
Creates a file filter that accepts files with the given extension. |
|
BasicFileFilter(String[] filters)
Creates a file filter from the given string array. |
|
BasicFileFilter(String[] filters,
String description)
Creates a file filter from the given string array and description. |
|
BasicFileFilter(String extension,
String description)
Creates a file filter that accepts the given file type. |
Method Summary | |
---|---|
boolean |
accept(File f)
Return true if this file should be shown in the directory pane, false if it shouldn't. |
boolean |
accept(File dir,
String name)
|
void |
addExtension(String extension)
Adds a filetype "dot" extension to filter against. |
String |
getDescription()
Returns the human readable description of this filter. |
static String |
getExtension(File f)
Return the extension of a file's name. |
static String |
getExtension(String name)
Return the extension of a file's name. |
boolean |
isExtensionListInDescription()
Returns whether the extension list (.jpg, .gif, etc) should show up in the human readable description. |
void |
setDescription(String description)
Sets the human readable description of this filter. |
void |
setExtensionListInDescription(boolean b)
Determines whether the extension list (.jpg, .gif, etc) should show up in the human readable description. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BasicFileFilter()
addExtension(java.lang.String)
public BasicFileFilter(String extension)
addExtension(java.lang.String)
public BasicFileFilter(String extension, String description)
addExtension(java.lang.String)
public BasicFileFilter(String[] filters)
addExtension(java.lang.String)
public BasicFileFilter(String[] filters, String description)
addExtension(java.lang.String)
Method Detail |
---|
public boolean accept(File f)
accept
in class FileFilter
FileFilter.accept(java.io.File)
public static String getExtension(String name)
public static String getExtension(File f)
f
- the File.public void addExtension(String extension)
public String getDescription()
getDescription
in class FileFilter
public void setDescription(String description)
public void setExtensionListInDescription(boolean b)
public boolean isExtensionListInDescription()
public boolean accept(File dir, String name)
accept
in interface FilenameFilter
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |