JFileChooser hangs

H

Hansi

Hi there.

I am very frustrated, cause an applet, i developed 2 years ago, now does
not work anymore.

I tried to find the reason and found this:

Older versions of Browsers and SUN-VM work, newest version does not.

The problem occurs, when a JFileChooser ist created the second time:



JFileChooser jfc= New JFileChooser();



This line of code is in a function, and when the function is called the
second time, the application hangs and does not execute the lines of
code under this line.

The hang causes the browser to hang too.
This effekt is in IE7 und Firefox 2.

Any idea, what I could do to fix this?

Please help, Regards, Hans
 
T

Tom Hawtin

Hansi said:
I am very frustrated, cause an applet, i developed 2 years ago, now does
not work anymore.
The problem occurs, when a JFileChooser ist created the second time:

Have you tried getting a stack trace with jstack?

And, as ever, are you sure you are confining Swing activity to the Event
Dispatch Thread (EDT)?

Tom Hawtin
 
A

Andrew Thompson

Hansi wrote:
....
I am very frustrated, cause an applet...
URL?

..., i developed 2 years ago, now does
not work anymore. ....
JFileChooser jfc= New JFileChooser();

That would not compile, care to link to your
*real* code instead?
This line of code is in a function, and when the function is called the
second time, the application hangs and does not execute the lines of
code under this line.

As an aside. Your applet is signed?

Andrew T.
 
H

Hansi

Andrew said:
Hansi wrote:
...

That would not compile, care to link to your
*real* code instead?


As an aside. Your applet is signed?

Andrew T.

Yes, i signed the applet, to get local fileaccess.
I cannot get any infos from the System.out.... because the VM crashes
and there is no response.

What is this:
confining Swing activity to the Event Dispatch Thread (EDT) ??

Can anyone send an example?

The code is:


JFileChooser jfc = new JFileChooser();
if (lastopenpath.length()>0){
jfc.setCurrentDirectory(new File(lastopenpath));
}
jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
jfc.setMultiSelectionEnabled(true);
jfc.setDragEnabled(false);
//int res=jfc.showOpenDialog(new JFrame());
int res=jfc.showOpenDialog(null);

if (res==JFileChooser.APPROVE_OPTION){
....
}
 
T

Tom Hawtin

Hansi said:
I cannot get any infos from the System.out.... because the VM crashes
and there is no response.

When you mean the VM crashes, do you mean that the whole browser process
exits abruptly, or that your applets stops responding, or something in
between?
What is this:
confining Swing activity to the Event Dispatch Thread (EDT) ??

Swing, like the vast majority of GUI APIs, is single threaded. You need
to make sure all your Swing code is on one thread (the EDT). You can
check it using java.awt.EventQueue.isDispatchThread().

BTW: Your applet wont work on Vista anyway. Plug-ins cannot access files
outside of a restricted area, apparently. I suggest running it under
WebStart instead.

Tom Hawtin
 
A

Andrew Thompson

Tom Hawtin wrote:
....
BTW: Your applet wont work on Vista anyway. Plug-ins cannot access files
outside of a restricted area, apparently. I suggest running it under
WebStart instead.

I second that. If you rework the code to use the
JNLP API, it would not even need to be signed,
to access local files.
E.G. <http://www.physci.org/jws/#fs>

OTOH, given it is already signed, it would be a
simple matter to launch the applet via web-start
'as is'.

What was that URL (of your applet)?

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,059
Members
48,769
Latest member
Clifft

Latest Threads

Top