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
FileNameExtensionFilter that will show jpg files:
FileFilter filter = new FileNameExtensionFilter("JPEG file", "jpg", "jpeg");
JFileChooser fileChooser = ...;
fileChooser.addChoosableFileFilter(filter);
FileFilter, javax.swing.JFileChooser#setFileFilter , javax.swing.JFileChooser#addChoosableFileFilter , javax.swing.JFileChooser#getFileFilter
| Modifier and Type | Field and Description |
|---|---|
| private final String | |
| private final String[] | |
| private final String[] |
| Access | Constructor and Description |
|---|---|
| public | FileNameExtensionFilter(String
textual description for the filter, may be
description, String... nullthe accepted file name extensions extensions)Creates a |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the file is to be accepted, false otherwisethe f)File to testImplements abstract javax. Tests the specified file, returning true if the file is accepted, false otherwise. |
| public String | Returns: the description of this filterImplements abstract javax. The description of this filter. |
| public String[] | Returns: the set of file name extensions files are tested againstReturns the set of file name extensions files are tested against. |
| public String | Returns: a string representation of thisFileNameExtensionFilterOverrides java. Returns a string representation of the |
| description | back to summary |
|---|---|
| private final String description | |
| extensions | back to summary |
|---|---|
| private final String[] extensions | |
| lowerCaseExtensions | back to summary |
|---|---|
| private final String[] lowerCaseExtensions | |
| FileNameExtensionFilter | back to summary |
|---|---|
| public FileNameExtensionFilter(String description, String... extensions) Creates a
| |
| accept | back to summary |
|---|---|
| public boolean accept(File f) Implements abstract javax. 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
| |
| getDescription | back to summary |
|---|---|
| public String getDescription() Implements abstract javax. The description of this filter. For example: "JPG and GIF Images."
| |
| getExtensions | back to summary |
|---|---|
| public String[] getExtensions() Returns the set of file name extensions files are tested against.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation of the
| |