
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 enable the display of hidden files in a JFileChooser in Java?
Set the following to FALSE to enable the display of hidden files −
JFileChooser file = new JFileChooser(); file.setFileHidingEnabled(false);
The following is an example to enable the display of hidden files in a JFileChooser −
Example
package my; import javax.swing.JFileChooser; public class SwingDemo { public static void main(String[] args) { JFileChooser file = new JFileChooser(); file.setMultiSelectionEnabled(false); file.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); file.setFileHidingEnabled(false); int res = file.showOpenDialog(null); if (res == JFileChooser.APPROVE_OPTION) { java.io.File f = file.getSelectedFile(); System.err.println(f.getPath()); } } }
The output is as follows. This displays the hidden files and directories.
Above, the “amit.txt” abd “desktop.ini” were hidden files and are now visible.
Advertisements