JFileChooser hangs sometimes
Asked Answered
M

4

7

I am running into the problem of the "hanging JFileChooser" as described in the following threads:

http://forums.sun.com/thread.jspa?threadID=5309960

http://forums.sun.com/thread.jspa?threadID=724817

http://x86.sun.com/thread.jspa?threadID=5275999&messageID=10156541

I am using JVM 1.6.0_07-b06. It happens on Windows XP as well as on Windows Vista.

Has anybody found a workaround for this yet?

Melliemelliferous answered 20/11, 2008 at 10:48 Comment(0)
D
5

There's a bug where if you a networked drive mapped on the desktop, it can sometimes hang on the JFileChooser. That or it might be a shortcut to a networked drive. Something along those lines...

Dipetalous answered 20/11, 2008 at 16:57 Comment(1)
A second floppy drive (remember them?) might also be a problem I think.Godber
C
2

I've run into this myself and the updates didn't help. Strangely enough, removing all zip files (particularly large ones) from my desktop (JFileChooser's default location) solved the issue.

Clava answered 20/11, 2008 at 14:5 Comment(3)
I do not have any zip files on my desktop nor in the file chooser startup locationMelliemelliferous
Sorry that didn't help. As an FYI, here the link to the discussion regarding JFileChooser and large zip files on the desktop forums.sun.com/…Clava
Oh man, this sure helped ME. I can't get how Java is getting THIS ridiculous now. I have been using it at college/hobby and ofc work for going on 9 years now and it is really getting annoying.Bimetallism
E
0

The .10 update is supposed to fix the zipfile related one.

Enginery answered 26/11, 2008 at 1:22 Comment(0)
I
0

Yes, it was a bug, but I believe recent versions of Java no longer have it.
There are a few workarounds(although they are all dirty hacks):

  1. Use a thread to wait until it was initialized
  2. Reuse the same JFileChooser(store it in a variable) instead of creating new ones. If possible, lazily initialize them:

public static JFileChooser chooser = null;

public static void doSomething(){
    if(chooser==null)
         chooser = new JFileChooser();
    //use JFileChooser
}

This way your users have to wait less... but they still will need to wait. The only way to really fix this is to update your JRE.

Illaudable answered 26/11, 2008 at 20:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.