Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with JFileChooser - very slow

843807May 24 2004 — edited May 30 2004
I've built an Applet that by a button pressing, open a JFILECHOOSER to select multiple files. When I select the files and press OPEN, the dialog is very slowly, for 900 files about five minutes to continue the normal process. I use this applet in Windows and JDK 1.4.1_02.
There is a workaround or resolution for this inconvenience.

This is my code for management FILECHOOSER:

// create file chooser
JFileChooser filePicker = new JFileChooser();

// allow only selection of directories
filePicker.setFileSelectionMode(JFileChooser.FILES_ONLY);
// multiple file selection allowed
filePicker.setMultiSelectionEnabled(true);
// no "all files" option
filePicker.setAcceptAllFileFilterUsed(false);
// set a filter to show only "good" files or directories
ChoosableFileFilter filter = new ChoosableFileFilter(FILTER_EXT, FILTER_DESC);
filePicker.setFileFilter(filter);

// show the dirchooser in a pop-up
int returnVal = filePicker.showOpenDialog((Component) e.getSource());
if (returnVal == JFileChooser.APPROVE_OPTION) {
// get all selected files and add them to the fileList
File[] selectedFiles = filePicker.getSelectedFiles();

// Clear all element il list
fileListModel.clear();
for (int i =0; i <selectedFiles.length; i++) {
fileListModel.addElement(selectedFiles);
} // end for
} // end approve if
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 27 2004
Added on May 24 2004
1 comment
309 views