FileFilter Class
Package: javax.swing
This abstract class lets you create a class that can filter the files displayed by the JFileChooser class. For example, you can use this class to create a filter that will display only files with a certain filename extension in the file chooser. (For more information about file choosers and the JFileChooser class, see JFileChooser Class.)
class JavaFilter
extends javax.swing.filechooser.FileFilter
Methods
|
Method |
Description |
|
|
You must implement this method to return |
|
|
You must implement this method to return the description string that is displayed in the Files of Type drop-down list in the chooser dialog box. |
The getDescription method simply returns the text displayed in the Files of Type drop-down list. You usually implement it with a single return statement that returns the description. Here’s an example:
public String getDescription()
{
return “Java files (*.java)”;
}
Here, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access