|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.filechooser.FileFilter
GenericFileFilter
public class GenericFileFilter
This is a generic file filter. The class allows for the addition and removal of extensions. After instanciating an instance of this class, the user can add all extensions to be accepted by the filter. This allows for custom file filters without the need to create a new class for each different filter.
Field Summary | |
---|---|
(package private) java.lang.String |
filterDesc
The filter description |
(package private) java.util.ArrayList |
validExt
Holds the list of valid extensions. |
Constructor Summary | |
---|---|
GenericFileFilter()
|
Method Summary | |
---|---|
boolean |
accept(java.io.File f)
Returns true on directories and files with supported extensions. |
void |
addExtension(java.lang.String ext)
Adds the passed in extension to the list of accepted extensions. |
void |
clearExtensions()
Clears the list of extensions to accept. |
java.lang.String |
getDescription()
Returns the description string of the FileFilter. |
static java.lang.String |
getExtension(java.io.File f)
Deterimines the file extension of the passed in file, then returns it. |
void |
removeExtension(java.lang.String ext)
Removes the passed in extension from the list of accepted extensions. |
void |
setDescription(java.lang.String newDesc)
Sets the description of the FileFilter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
java.util.ArrayList validExt
java.lang.String filterDesc
Constructor Detail |
---|
public GenericFileFilter()
Method Detail |
---|
public boolean accept(java.io.File f)
true
on directories and files with supported extensions.
This function searches an array list of extensions to see if any
match the passed in file's extension.
accept
in class javax.swing.filechooser.FileFilter
f
- File to test for acceptance
true
on accepted; false
otherwise.public java.lang.String getDescription()
getDescription
in class javax.swing.filechooser.FileFilter
public void setDescription(java.lang.String newDesc)
newDesc
- Description to use for the filter.public void clearExtensions()
public void removeExtension(java.lang.String ext)
ext
- The extension to remove.public void addExtension(java.lang.String ext)
ext
- The extension to add.public static java.lang.String getExtension(java.io.File f)
f
- The file to determine the extension of
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |