- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create FileFilter for JFileChooser in Java and display File Type accordingly?
To create FileFilter, use the FileNamExtensionFilter class. The following is an example to display File Type in JFileChooser −
Example
import javax.swing.JFileChooser; import javax.swing.filechooser.FileNameExtensionFilter; public class SwingDemo { public static void main(String[] args) { JFileChooser file = new JFileChooser(); file.setAcceptAllFileFilterUsed(false); FileNameExtensionFilter extFilter = new FileNameExtensionFilter("JPEG file", "jpg", "jpeg"); file.addChoosableFileFilter(extFilter); file.showOpenDialog(null); } }
Output
- Related Articles
- How to enable the display of hidden files in a JFileChooser in Java?
- How to create a Feature file for Cucumber in Java?
- How to get Directories from JFileChooser in Java
- How to create a step definition file for Cucumber in Java?
- How to create a test runner file for Cucumber in Java?
- How to use FileFilter interface in lambda expression in Java?\n
- Get the path of the file selected in the JFileChooser component with Java
- How to create and store property file dynamically in Java?
- How to create a pdf file in Java?
- How to read data from PDF file and display on console in Java?
- How to create and write JSON array to a file in java?
- How to enable multiple selections in a JFileChooser Dialog with Java?
- Display File class constants in Java
- How to display errors in PHP file?
- How to Write/create a JSON file using Java?

Advertisements