acm.util
Class FileChooserFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by 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.


Constructor Summary
FileChooserFilter()
          Creates a default FileChooserFilter.
FileChooserFilter(String pattern)
          Creates a FileChooserFilter that accepts filenames matching the specified pattern.
FileChooserFilter(String pattern, String description)
          Creates a FileChooserFilter that accepts filenames matching the specified pattern.
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileChooserFilter

public FileChooserFilter()
Creates a default FileChooserFilter. Such a FileChooserFilter is useful only if the client overrides the accept and getDescription methods.


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")
 

Parameters:
pattern - The filename pattern

FileChooserFilter

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.

Parameters:
pattern - The filename pattern
description - The description of the files for inclusion in the dialog
Method Detail

accept

public boolean accept(File file)
Returns true if the specified file should be accepted by the filter.

Specified by:
accept in class FileFilter
Parameters:
file - The File object representing the file
Returns:
true if the specified file should be accepted

getDescription

public String getDescription()
Returns a description of the accepted files.

Specified by:
getDescription in class FileFilter