|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.filechooser.FileFilter
com.lamatek.util.JFileFilter
public class JFileFilter
Provides a functional javax.swing.filechooser.FileFilter object to filter files accepted in a JFileChooser.
Users should create a JFileFilter, set it's description, and add each extension (with the '.') that this filter should accept. Then add the new JFileFilter to the JFileChooser by calling the JFileChooser.addChoosableFileFilter(FileFilter) method.
| Constructor Summary | |
|---|---|
JFileFilter()
Creates and initializes a new FileFilter. |
|
JFileFilter(java.lang.String description)
Create a new FileFilter with the given description. |
|
JFileFilter(java.lang.String description,
java.lang.String extension)
Creates a new FileFilter with the given description, that accepts the given extension. |
|
JFileFilter(java.lang.String description,
java.lang.String extension,
boolean acceptDirectories)
Creates a new FileFilter with the given description that accepts the given extension and accepts/unaccepts directories. |
|
| Method Summary | |
|---|---|
boolean |
accept(java.io.File file)
Denotes whether the file fits this filters acceptance list. |
void |
acceptDirectories(boolean acceptDirectories)
Sets whether this FileFiler should accept and display directories. |
void |
addExtension(java.lang.String extension)
Adds an extension that this filter will accept. |
java.lang.String |
getDescription()
Returns the textual description for this filter. |
void |
setDescription(java.lang.String description)
Sets the description that will be shown in the JFileChooser drop-down list for this filter. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JFileFilter()
public JFileFilter(java.lang.String description)
description - The text description for this filter.
public JFileFilter(java.lang.String description,
java.lang.String extension)
description - The text description for this filter.filter - The file extension this filter will accept.
public JFileFilter(java.lang.String description,
java.lang.String extension,
boolean acceptDirectories)
description - The text description for this filter.extension - The file extension this filter will accept.acceptDirectories - Denotes whether this filter should accept directories.| Method Detail |
|---|
public void acceptDirectories(boolean acceptDirectories)
acceptDirectories - Denotes whether this FileFilter should accept directories.public void setDescription(java.lang.String description)
description - Text description for this file filter.public void addExtension(java.lang.String extension)
For example, you could create a JFileFilter that accepts all graphics formats like so:
JFileFilter gFilter = new JFileFilter();
gFilter.setDescription("Graphic Files");
gFilter.addExtension("gif");
gFilter.addExtension("jpg");
gFilter.addExtension("bmp");
fileChooser.addChoosableFileFilter(gFilter);
extension - The extension (without a period) to accept.public java.lang.String getDescription()
getDescription in class javax.swing.filechooser.FileFilterpublic boolean accept(java.io.File file)
accept in class javax.swing.filechooser.FileFilterfile - The file to check.
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||