Synergy Home Page

au.edu.swin.synergy.lib.io
Class BFileFilter

java.lang.Object
  |
  +--javax.swing.filechooser.FileFilter
        |
        +--au.edu.swin.synergy.lib.io.BFileFilter

public class BFileFilter
extends FileFilter

An extension of the FileFilter class to allow filtering of only those filetypes that are necessary to display in a JFileChooser

Author:
Matthew Evans

Constructor Summary
BFileFilter()
          Creates a file filter.
BFileFilter(String extension)
          Creates a file filter that accepts files with the given extension.
BFileFilter(String extension, String description)
          Creates a file filter that accepts the given file type, and is supplied with an appropriate description.
 
Method Summary
 boolean accept(File file)
          Returns whether this file should be displayed in a JFileChooser
 void addExtension(String extension)
          Adds an extension for filtering.
 String getDescription()
          Returns a description of this file filter.
 String getExtension(File file)
          Return only the extension part of the specified file
 void setDescription(String description)
          Sets the description of this filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BFileFilter

public BFileFilter()
Creates a file filter. If no filters are added, then all files are accepted.

BFileFilter

public BFileFilter(String extension)
Creates a file filter that accepts files with the given extension. Example: new BFileFilter("jpg");
See Also:
addExtension(java.lang.String)

BFileFilter

public BFileFilter(String extension,
                   String description)
Creates a file filter that accepts the given file type, and is supplied with an appropriate description.
Parameters:
extension - the extension to filter against
description - a description of this file filter
Method Detail

accept

public boolean accept(File file)
Returns whether this file should be displayed in a JFileChooser
Parameters:
file - the file to accept or reject
Returns:
true if the file was accepted; false otherwise
Overrides:
accept in class FileFilter

getExtension

public String getExtension(File file)
Return only the extension part of the specified file
Parameters:
the - file to act upon
Returns:
the extension part of the filename

addExtension

public void addExtension(String extension)
Adds an extension for filtering. eg. "tit".
Parameters:
extension - the filetype extension to add to the file filter

getDescription

public String getDescription()
Returns a description of this file filter. Eg. "Cohesion Project files (*.cop)"
Returns:
a description of the file filter
Overrides:
getDescription in class FileFilter

setDescription

public void setDescription(String description)
Sets the description of this filter. Eg. "Cohesion Project files"
Parameters:
description - a description of the filter

Synergy Home Page