This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.swing.filechooser
class FileNameExtensionFilter

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

public final class FileNameExtensionFilter
extends FileFilter

An implementation of {@code FileFilter} that filters using a specified set of extensions. The extension for a file is the portion of the file name after the last ".". Files whose name does not contain a "." have no file name extension. File name extension comparisons are case insensitive.

The following example creates a {@code FileNameExtensionFilter} that will show {@code jpg} files:

 FileFilter filter = new FileNameExtensionFilter("JPEG file", "jpg", "jpeg");
 JFileChooser fileChooser = ...;
 fileChooser.addChoosableFileFilter(filter);
 


Constructor Summary
FileNameExtensionFilter(String description, String[] extensions)

          Creates a with the specified description and file name extensions.
 
Method Summary
 boolean

          Tests the specified file, returning true if the file is accepted, false otherwise.
 String

          The description of this filter.
 String[]

          Returns the set of file name extensions files are tested against.
 String

          Returns a string representation of the .
 
Methods inherited from class javax.swing.filechooser.FileFilter
accept, getDescription
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileNameExtensionFilter

public FileNameExtensionFilter(String description,
                               String[] extensions)
Creates a {@code FileNameExtensionFilter} with the specified description and file name extensions. The returned {@code FileNameExtensionFilter} will accept all directories and any file with a file name extension contained in {@code extensions}.

Parameters:
description - textual description for the filter, may be {@code null}
extensions - the accepted file name extensions
Method Detail

accept

public boolean accept(File f)
Tests the specified file, returning true if the file is accepted, false otherwise. True is returned if the extension matches one of the file name extensions of this {@code FileFilter}, or the file is a directory.

Overrides:
accept in class FileFilter
Parameters:
f - the {@code File} to test
Returns:
true if the file is to be accepted, false otherwise

getDescription

public String getDescription()
The description of this filter. For example: "JPG and GIF Images."

Overrides:
getDescription in class FileFilter
Returns:
the description of this filter

getExtensions

public String[] getExtensions()
Returns the set of file name extensions files are tested against.

Returns:
the set of file name extensions files are tested against

toString

public String toString()
Returns a string representation of the {@code FileNameExtensionFilter}. This method is intended to be used for debugging purposes, and the content and format of the returned string may vary between implementations.

Overrides:
toString in class Object
Returns:
a string representation of this {@code FileNameExtensionFilter}


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.