tools
Class ImageFilter
java.lang.Object
javax.swing.filechooser.FileFilter
tools.ImageFilter
public class ImageFilter
- extends javax.swing.filechooser.FileFilter
This class acts as a FileFilter
and accepts only JPEG image files.
This code was taken from
http://java.sun.com/docs/books/tutorial/uiswing/examples/components/FileChooserDemo2Project/src/components/ImageFilter.java
and modified for own purposes.
Field Summary |
static java.lang.String |
jpeg
|
static java.lang.String |
jpg
|
Method Summary |
boolean |
accept(java.io.File f)
Accept all directories and all jpg files. |
java.lang.String |
getDescription()
Returns the description of this filter. |
static java.lang.String |
getExtension(java.io.File f)
Get the extension of a file |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
jpeg
public static final java.lang.String jpeg
- See Also:
- Constant Field Values
jpg
public static final java.lang.String jpg
- See Also:
- Constant Field Values
ImageFilter
public ImageFilter()
accept
public boolean accept(java.io.File f)
- Accept all directories and all jpg files.
- Specified by:
accept
in class javax.swing.filechooser.FileFilter
getExtension
public static java.lang.String getExtension(java.io.File f)
- Get the extension of a file
- Parameters:
f
-
- Returns:
- String - the file extension
getDescription
public java.lang.String getDescription()
- Returns the description of this filter.
The description is used i.e. in the file save dialog to describe the filter.
- Specified by:
getDescription
in class javax.swing.filechooser.FileFilter