|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.filechooser.FileFilter
com.ccg.swing.FilenameFilter
public class FilenameFilter
Builds a "file filter" which matches file names and is suitable
for use with the Swing JFileChooser.
This is a helper class which simplifies the process of building
file filters for Swing. It aids in the
following:
Here is a quick example of how one might use this object to select only HTML files (which end with "htm" OR "html" extensions):
public void addFilter(JFileChooser fc) {
fc.addChoosableFileFilter(new FilenameFilter("*.html;*.htm",
"HTML Documents"));
}
Please note that the "match" filter is only applied to file names and that ALL directories are accepted by this filter.
FileFilter,
JFileChooser| Field Summary | |
|---|---|
(package private) String |
_Description
|
(package private) FilenameFilterWild |
_Filter
|
| Constructor Summary | |
|---|---|
FilenameFilter(String match,
String des)
Fully construct and initialize the object (ready for use). |
|
| Method Summary | |
|---|---|
boolean |
accept(File f)
Returns true if the file passed matches one of the acceptable forms. |
String |
getDescription()
Get the text description of the filter (what to show user). |
String |
toString()
The text description of the filter (what to show user). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
FilenameFilterWild _Filter
String _Description
| Constructor Detail |
|---|
public FilenameFilter(String match,
String des)
match - One or more "wild" strings (separated by semi-colons) which
describe what files should be accepted. For example: "*.txt" or
"*.htm;*.html". Must NOT be null.| Method Detail |
|---|
public boolean accept(File f)
accept in class FileFilterf - File to check (we handle null).
public String getDescription()
getDescription in class FileFilterpublic String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||