- 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 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
- Related Articles
- How to enable the display of hidden files in a JFileChooser in Java?
- How to get Directories from JFileChooser in Java
- How to enable row selection in a JTable with Java
- How to keep selections highlighted in a Tkinter Listbox?
- How can we clear all selections in Java Swing JList?
- How to create a Confirmation Dialog Box in Java?
- How to make custom dialog with custom dialog view actions in android?
- How to create a dialog with Neutral options?
- How to create FileFilter for JFileChooser in Java and display File Type accordingly?
- How to enable webview java script in android?
- Get the path of the file selected in the JFileChooser component with Java
- How to dismiss the dialog with click on outside of the dialog?
- How to configure Gson to enable versioning support in Java?
- How to work with Alerts Dialog box in ReactNative?
- How to disable/ enable checkbox with jQuery?

Advertisements