Class JFileFilter

java.lang.Object
  extended by javax.swing.filechooser.FileFilter
      extended by JFileFilter

public class JFileFilter
extends javax.swing.filechooser.FileFilter

class JFileFilter A simple FileFilter class that works by filename extension, like one in JDK demo called ExtentionFilter to be released in future Swing. Based on code from p 393 in Java Cookbook by Ian Darwin, O'Reilly INC, 2001. Used with permission. Source for entire text can be downloaded at http://javacook.darwinsys.com. 11 December 2001 Revised: 14 December 2001 by Victor Spears implemented by James Harney for Cole Terrorist Attack Project.


Field Summary
protected  java.lang.String description
           
protected  java.util.ArrayList exts
           
 
Constructor Summary
JFileFilter()
           
 
Method Summary
 boolean accept(java.io.File f)
          Tells whether the file is acceptable; either a directory or a file with an extension from the ArrayList exts (set with addType())
 void addType(java.lang.String s)
          adds a new file extension to the list of those allowable
 java.lang.String getDescription()
          gets the description string for the file types desired.
 void setDescription(java.lang.String s)
          Sets the description string for the file types desired.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

description

protected java.lang.String description

exts

protected java.util.ArrayList exts
Constructor Detail

JFileFilter

public JFileFilter()
Method Detail

addType

public void addType(java.lang.String s)
adds a new file extension to the list of those allowable

Parameters:
s - the new allowable extension. Once added, the 'accept' method will return true for files with this extension

accept

public boolean accept(java.io.File f)
Tells whether the file is acceptable; either a directory or a file with an extension from the ArrayList exts (set with addType())

Specified by:
accept in class javax.swing.filechooser.FileFilter
Parameters:
f - file to be queried
Returns:
true if the file 'f' is a directory or has an appropriate extension

setDescription

public void setDescription(java.lang.String s)
Sets the description string for the file types desired. Has no effect on the operation of the file filter other than the getter, below

Parameters:
s - Desired description of the file types allowed

getDescription

public java.lang.String getDescription()
gets the description string for the file types desired.

Specified by:
getDescription in class javax.swing.filechooser.FileFilter
Returns:
the String description of the file types allowed