|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.filechooser.FileFilter | +--kiwi.io.FileExtensionFilter
A convenience implementation of FileFilter
that filters out
all files except for those type extensions that it knows about.
Extensions are of the type ".foo", which is typically found on Windows and Unix systems, but not on MacOS. Case is ignored.
Example - create a new filter that filters out all files but gif and jp image files:
JFileChooser chooser = new JFileChooser(); ExampleFileFilter filter = new FileExtensionFilter( new String{"gif", "jpg"}, "JPEG & GIF Images") chooser.addChoosableFileFilter(filter); chooser.showOpenDialog(this);
Constructor Summary | |
FileExtensionFilter()
Construct a new FileExtensionFilter . |
|
FileExtensionFilter(String extension)
Construct a new FileExtensionFilter that accepts files with
the given extension. |
|
FileExtensionFilter(String[] extensions)
Construct a new FileExtensionFilter that accepts the given
extensions. |
|
FileExtensionFilter(String[] extensions,
String description)
Construct a new FileExtensionFilter that accepts the given
extensions. |
|
FileExtensionFilter(String extension,
String description)
Construct a new FileExtensionFilter that accepts the given
file type. |
Method Summary | |
boolean |
accept(File f)
Filter a file. |
void |
addExtension(String extension)
Adds an extension to filter against. |
String |
getDescription()
Get the description of this filter |
String |
getExtension(File f)
Get the extension portion of a file's name . |
boolean |
isExtensionListInDescription()
Determine whether the extension list will appear as part of the description. |
void |
setDescription(String description)
Set the description for this filter. |
void |
setExtensionListInDescription(boolean flag)
Specify whether the extension list should appear as part of the description. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public FileExtensionFilter()
FileExtensionFilter
. If no extensions are
added to this filter, then all files will be accepted.addExtension(java.lang.String)
public FileExtensionFilter(String extension)
FileExtensionFilter
that accepts files with
the given extension. For example:
new FileExtensionFilter("jpg");
extension
- The extension.addExtension(java.lang.String)
public FileExtensionFilter(String extension, String description)
FileExtensionFilter
that accepts the given
file type. For example:
new FileExtensionFilter("jpg", "JPEG Image Images");
Note that the '.' before the extension is not needed. If provided, it will be ignored.
extension
- The extension.description
- A description of the extension.addExtension(java.lang.String)
public FileExtensionFilter(String[] extensions)
FileExtensionFilter
that accepts the given
extensions. For example:
new FileExtensionFilter(String {"gif", "jpg"});
Note that the '.' before the extension is not needed. If provided, it will be ignored.
extensions
- An array of extensions.addExtension(java.lang.String)
public FileExtensionFilter(String[] extensions, String description)
FileExtensionFilter
that accepts the given
extensions. For example:
new FileExtensionFilter(String {"gif", "jpg"}, "Image Files");
Note that the '.' before the extension is not needed. If provided, it will be ignored.
extensions
- An array of extensions.description
- A description for these extensions.addExtension(java.lang.String)
Method Detail |
public boolean accept(File f)
f
- The File
to filter.getExtension(java.io.File)
public String getExtension(File f)
f
- The file.FileFilter.accept(java.io.File)
public void addExtension(String extension)
For example, the following code will create a filter that accepts only files whose names end with ".jpg" or ".tif":
FileExtensionFilter filter = new FileExtensionFilter();
filter.addExtension("jpg");
filter.addExtension("tif");
Note that the '.' before the extension is not needed. If provided, it will be ignored.
extension
- The extension to add.public String getDescription()
setDescription(java.lang.String)
,
setExtensionListInDescription(boolean)
,
isExtensionListInDescription()
public void setDescription(String description)
description
- The new description.setDescription(java.lang.String)
,
setExtensionListInDescription(boolean)
,
isExtensionListInDescription()
public void setExtensionListInDescription(boolean flag)
setDescription()
.flag
- A flag specifying whether or not the extensions should be
listed in the description.getDescription()
,
setDescription(java.lang.String)
,
isExtensionListInDescription()
public boolean isExtensionListInDescription()
getDescription()
,
setDescription(java.lang.String)
,
setExtensionListInDescription(boolean)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |