dkp
dkp

Reputation: 835

JFileChooser hangs sometimes

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?

Upvotes: 7

Views: 2619

Answers (4)

luiscubal
luiscubal

Reputation: 25161

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.

Upvotes: 0

Tim Williscroft
Tim Williscroft

Reputation: 3756

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

Upvotes: 0

Stephane Grenier
Stephane Grenier

Reputation: 15925

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...

Upvotes: 5

Brendan Cashman
Brendan Cashman

Reputation: 4928

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.

Upvotes: 2

Related Questions