Package info.monitorenter.gui.chart.io
Class FileFilterExtensions
- java.lang.Object
-
- javax.swing.filechooser.FileFilter
-
- info.monitorenter.gui.chart.io.FileFilterExtensions
-
- All Implemented Interfaces:
INameFilter
public final class FileFilterExtensions extends javax.swing.filechooser.FileFilter implements INameFilter
Configureable implementation of
FileFilterthat filters files by their extension (e.g.: ".txt").The extension Strings are provided to the constructor (no configuration of initialized instance provided yet) and have to be the sole extension without the dot.
This class is most often used to configure
JFileChooserdialogs. Therefore it accepts all directories to allow browsing.Example usage:
... JFileChooser fileChooser = new JFileChooser(); FileFilter soundFileFilter = new FileFilterExtensions(new String[]{"wav","mp3"}); fileChooser.setFileFilter(soundFileFilter); ...- Author:
-
-
-
Constructor Summary
Constructors Constructor Description FileFilterExtensions(java.lang.String[] extensionsWithoutDot)Creates an instance that will accept files with the given extensions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaccept(java.io.File pathname)booleanaccept(java.lang.String urlstring)Accept the file denoted by the given url String.java.lang.StringgetDescription()
-
-
-
-
Constructor Detail
-
FileFilterExtensions
public FileFilterExtensions(java.lang.String[] extensionsWithoutDot) throws java.lang.IllegalArgumentExceptionCreates an instance that will accept files with the given extensions.- Parameters:
extensionsWithoutDot- A String[] containing extension strings without the dot like: .new String[]{"bat","txt","dict"}- Throws:
java.lang.IllegalArgumentException- if the given extensions are inivalid.
-
-
Method Detail
-
accept
public boolean accept(java.io.File pathname)
- Specified by:
acceptin classjavax.swing.filechooser.FileFilter- See Also:
FileFilter.accept(java.io.File)
-
accept
public boolean accept(java.lang.String urlstring)
Description copied from interface:INameFilterAccept the file denoted by the given url String.- Specified by:
acceptin interfaceINameFilter- Parameters:
urlstring- a String in url format denoting a file.- Returns:
- true if the file denoted by the given url String is accepted.
- See Also:
INameFilter.accept(String)
-
getDescription
public java.lang.String getDescription()
- Specified by:
getDescriptionin classjavax.swing.filechooser.FileFilter- See Also:
FileFilter.getDescription()
-
-