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!

JFileChooser incredibly slow both to initialize and to change directories

843806Jun 28 2009 — edited Jun 29 2009
I have searched the forums for this and haven't found anything useful. I have the following code running in jre1.6.0_07:
JFileChooser objFileChooser = new JFileChooser();
		
objFileChooser.setAcceptAllFileFilterUsed(true);
objFileChooser.addChoosableFileFilter(new CookbookFileFilter());
objFileChooser.setMultiSelectionEnabled(false);
if(objFileChooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION)
	getModel().load(objFileChooser.getSelectedFile().getAbsolutePath());
the first line takes upwards of 20-30 seconds or more to get past when debugging - I don't know how long it takes when running without the debugger however the application does sit for a while after pressing the hotkey to activate the actionlistener. That's a problem, but if that was the only thing, I would do as another post suggested and initialize the jFileChooser from a separate thread during the initialization of the window or application...however, I also run into an issue whenever I change directories where it takes a subset of the initialization time(maybe 10-15 seconds instead of 20-30) to change the directory. This happens in both System and Cross-Platform Look and Feel-s.

I've looked into the issue with zip files and there are no (0) zip files(or archives of any kind) in the initial directory(My Documents folder). There is a small delay going to My Computer through Windows normally but it may be 1-2 seconds at most, and only sometimes. Notepad opens the Load / Save Dialogs within milliseconds and while I do understand Java is not Notepad, I'm willing to accept a few seconds (like maybe 5 or so), but not 20-30. I also looked into potentially using JDK 7 however I can't seem to get Eclipse to work with it and it consistently uses the JDK 6.

If a solution can not be found to this, then is there a way to hook into the dialog/control in order to change the mouse cursor to the 'wait' cursor and change it back when the directory is ready? I'd like to provide some communication to the user. Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 27 2009
Added on Jun 28 2009
8 comments
2,302 views