Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to enable multiple selections in a JFileChooser Dialog with Java?
To enable multiple selections in a JFileChooser dialog, use the setMultiSelectionEnabled() to be TRUE −
JFileChooser file = new JFileChooser(); file.setMultiSelectionEnabled(true);
The following is an example to enable multiple selections in a JFileChooser Dialog −
Example
package my;
import javax.swing.JFileChooser;
public class SwingDemo {
public static void main(String[] args) {
JFileChooser file = new JFileChooser();
file.setMultiSelectionEnabled(true);
file.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
file.setFileHidingEnabled(false);
if (file.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
java.io.File f = file.getSelectedFile();
System.err.println(f.getPath());
}
}
}
Output

Advertisements
