public class FileChooserFilter
extends javax.swing.filechooser.FileFilter
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.Constructor and Description |
---|
FileChooserFilter()
Creates a default
FileChooserFilter . |
FileChooserFilter(java.lang.String pattern)
Creates a
FileChooserFilter that accepts filenames matching the
specified pattern. |
FileChooserFilter(java.lang.String pattern,
java.lang.String description)
Creates a
FileChooserFilter that accepts filenames matching the
specified pattern. |
Modifier and Type | Method and Description |
---|---|
boolean |
accept(java.io.File file)
Returns
true if the specified file should be accepted by the
filter. |
java.lang.String |
getDescription()
Returns a description of the accepted files.
|
public FileChooserFilter()
FileChooserFilter
. Such a
FileChooserFilter
is useful only if the client overrides the
accept
and getDescription
methods.public FileChooserFilter(java.lang.String pattern)
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")
pattern
- The filename patternpublic FileChooserFilter(java.lang.String pattern, java.lang.String description)
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.
pattern
- The filename patterndescription
- The description of the files for inclusion in the dialogpublic boolean accept(java.io.File file)
true
if the specified file should be accepted by the
filter.accept
in class javax.swing.filechooser.FileFilter
file
- The File
object representing the filetrue
if the specified file should be acceptedpublic java.lang.String getDescription()
getDescription
in class javax.swing.filechooser.FileFilter