acm.util
Class FileChooserFilter
java.lang.Object
javax.swing.filechooser.FileFilter
acm.util.FileChooserFilter
public class FileChooserFilter
- extends FileFilter
This class extends javax.swing.filechooser.FileFilter
and exists primarily to avoid the ambiguity that arises because there is
also a FileFilter
class in java.io
. This
class also supports simple wildcard matching of filenames.
Method Summary |
boolean |
accept(File file)
Returns true if the specified file should be accepted by
the filter. |
String |
getDescription()
Returns a description of the accepted files. |
public FileChooserFilter()
- Creates a default
FileChooserFilter
. Such a
FileChooserFilter
is useful only if the client
overrides the accept
and getDescription
methods.
-
Usage: | FileChooserFilter filter = new FileChooserFilter(); |
public FileChooserFilter(String pattern)
- Creates a
FileChooserFilter
that accepts filenames
matching the specified pattern. This pattern consists of a
wildcard pattern (or a series of wildcard patterns separated
by semicolons) similar to those by a Unix shell. For example, to
match all files ending with the extensions .html
or .htm
, you could use the following constructor call:
new FileChooserPattern("*.html;*.htm")
-
Usage: | FileChooserFilter filter = new FileChooserFilter(pattern); |
Parameter: |
pattern | The filename pattern
|
|
public FileChooserFilter(String pattern,
String description)
- Creates a
FileChooserFilter
that accepts filenames
matching the specified pattern. This pattern consists of a
wildcard pattern (or a series of wildcard patterns separated
by semicolons) similar to those by a Unix shell. For example, to
match all files ending with the extensions .html
or .htm
, you could use the following constructor call:
new FileChooserPattern("*.html;*.htm")
This version of the constructor makes it possible to set the
description that appears in the dialog.
-
Usage: | FileChooserFilter filter = new FileChooserFilter(pattern, description); |
Parameters: |
pattern | The filename pattern
|
description | The description of the files for inclusion in the dialog
|
|
public boolean accept(File file)
- Returns
true
if the specified file should be accepted by
the filter.
-
Usage: | if (filter.accept(file)) . . . |
Parameter: |
file | The File object representing the file
|
|
Returns: | true if the specified file should be accepted
|
- Specified by:
accept
in class FileFilter
public String getDescription()
- Returns a description of the accepted files.
- Specified by:
getDescription
in class FileFilter