|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.filechooser.FileFilter | +--bill.util.gui.FileFilterExtension
This is an extension of the standard Java FileFilter class. It allows the
user to specify file extensions to be added to the "Save as Type" combo
box in a file selection dialog. When the user selects an entry from the
combo box it is applied as a filter to the list of files displayed in the
file list. Directories are displayed as are files that match the extension.
File extensions are not treated as case sensitive, all are converted to
lower case for comparison.
To create a filter that only shows .java and .jav files:
JFileChooser chooser = new JFileChooser();
FileFilterExtension filter = new FileFilterExtension ();
filter.addExtension ("java");
filter.addExtension ("jav");
filter.setDesciption ("Java Source Files");
chooser.setFileFilter (filter);
chooser.showOpenDialog (this);
Constructor Summary | |
FileFilterExtension()
Default class creator, initializes class instance variables but does not set any filter criteria. |
|
FileFilterExtension(String extension)
Alternate class creator, set the list of extensions to use as a filter to the value passed in. |
|
FileFilterExtension(String[] extensions)
Alternate class creator, set the list of extensions to use as a filter to the values passed in. Example: new FileFilterExtension(String {"java", "jav"}); If a "." is included before the extension it will be stripped off. |
|
FileFilterExtension(String[] extensions,
String description)
Alternate class creator, set the list of extensions to use as a filter to the values passed in. |
|
FileFilterExtension(String extension,
String description)
Alternate class creator, set the list of extensions to use as a filter to the value passed in. |
Method Summary | |
boolean |
accept(File f)
Determines whether the given file is accepted by this filter. |
void |
addExtension(String extension)
Adds the specified extenstion to the list of extensions we are filtering for. If a "." is included before the extension it will be stripped off. |
String |
getDescription()
Creates the formatted, readable description of this file extension filter. |
void |
setDescription(String description)
Sets the descriptive text portion of the file extension filter. For example: filter.setDescription ("Java Source Files"); |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FileFilterExtension()
public FileFilterExtension(String extension)
extension
- The extension to add to the list of extension known by
this filter.public FileFilterExtension(String extension, String description)
extension
- The extension to add to the list of extension known by
this filter.description
- Textual description of this file filter.public FileFilterExtension(String[] extensions)
public FileFilterExtension(String[] extensions, String description)
Method Detail |
public boolean accept(File f)
accept
in class FileFilter
true
if the file should be displayed,
false
if it should not.public void addExtension(String extension)
extension
- The extension to add to the extension filter list.public String getDescription()
getDescription
in class FileFilter
public void setDescription(String description)
description
- The text to set the descriptive text to.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |