@Deprecated
public class ExtensionFileFilter
extends javax.swing.filechooser.FileFilter
implements java.io.FilenameFilter
Extensions are of the type ".foo", which is typically found on Windows and Unix boxes, but not on Macintosh. Case is ignored.
Extension - create a new filter that filters out all files but gif and jpg image files:
JFileChooser chooser = new JFileChooser(); ExtensionFileFilter filter = new ExtensionFileFilter( new String{"gif", "jpg"}, "JPEG & GIF Images") chooser.addChoosableFileFilter(filter); chooser.showOpenDialog(this);
Note that as of Java 1.6, there is a FileNameExtensionFilter which replaces this class. See http://download.oracle.com/javase/6/docs/api/javax/swing/filechooser/FileNameExtensionFilter.html However, this class can be used with both java.awt.FileDialog and javax.swing.JFileChooser because it implements java.io.FilenameFilter and extends javax.swing.FilenameFilter.
Constructor and Description |
---|
ExtensionFileFilter()
Deprecated.
Creates a file filter.
|
ExtensionFileFilter(java.util.List extensions)
Deprecated.
Construct a file filter that filters out all files that do
not have one of the extensions in the given list.
|
ExtensionFileFilter(java.lang.String extension)
Deprecated.
Creates a file filter that accepts files with the given extension.
|
ExtensionFileFilter(java.lang.String[] filters)
Deprecated.
Creates a file filter from the given string array.
|
ExtensionFileFilter(java.lang.String[] filters,
java.lang.String description)
Deprecated.
Creates a file filter from the given string array and description.
|
ExtensionFileFilter(java.lang.String extension,
java.lang.String description)
Deprecated.
Creates a file filter that accepts the given file type.
|
Modifier and Type | Method and Description |
---|---|
boolean |
accept(java.io.File f)
Deprecated.
Return true if this file should be shown in the directory pane,
false if it shouldn't.
|
boolean |
accept(java.io.File directory,
java.lang.String name)
Deprecated.
Return true if this file should be shown in the directory pane,
false if it shouldn't.
|
void |
addExtension(java.lang.String extension)
Deprecated.
Adds a filetype "dot" extension to filter against.
|
java.lang.String |
getDefaultExtension()
Deprecated.
If the filter contains only one extension, return the extension
name.
|
java.lang.String |
getDescription()
Deprecated.
Returns the human readable description of this filter.
|
java.lang.String |
getExtension(java.io.File f)
Deprecated.
Return the extension portion of the file's name .
|
boolean |
isExtensionListInDescription()
Deprecated.
Returns whether the extension list (.jpg, .gif, etc) should
show up in the human readable description.
|
void |
setDescription(java.lang.String description)
Deprecated.
Sets the human readable description of this filter.
|
void |
setExtensionListInDescription(boolean b)
Deprecated.
Determines whether the extension list (.jpg, .gif, etc) should
show up in the human readable description.
|
java.lang.String |
toString()
Deprecated.
Return a string description of this filter.
|
public ExtensionFileFilter()
addExtension(String)
public ExtensionFileFilter(java.lang.String extension)
addExtension(String)
public ExtensionFileFilter(java.lang.String extension, java.lang.String description)
addExtension(String)
public ExtensionFileFilter(java.lang.String[] filters)
addExtension(String)
public ExtensionFileFilter(java.lang.String[] filters, java.lang.String description)
addExtension(String)
public ExtensionFileFilter(java.util.List extensions)
extensions
- A list of extensions, each of which is
a String.public boolean accept(java.io.File f)
Files that begin with "." are ignored.
This method is used by javax.swing.JFileChoosers,
accept
in class javax.swing.filechooser.FileFilter
accept(File, String)
,
getExtension(File)
,
FileFilter.accept(File)
public boolean accept(java.io.File directory, java.lang.String name)
Files that begin with "." are ignored.
This method is used by java.awt.FileDialog.
accept
in interface java.io.FilenameFilter
directory
- The directory in which the file was found.name
- The name of the file.accept(File)
,
getExtension(File)
,
FileFilter.accept(File)
public java.lang.String getDefaultExtension()
public java.lang.String getExtension(java.io.File f)
public void addExtension(java.lang.String extension)
public java.lang.String getDescription()
getDescription
in class javax.swing.filechooser.FileFilter
setDescription(String)
,
setExtensionListInDescription(boolean)
,
isExtensionListInDescription()
,
FileFilter.getDescription()
public void setDescription(java.lang.String description)
public void setExtensionListInDescription(boolean b)
getDescription()
,
isExtensionListInDescription()
public boolean isExtensionListInDescription()
getDescription()
public java.lang.String toString()
toString
in class java.lang.Object
getDescription()