Link to home
Create AccountLog in
Avatar of CatDevlp00
CatDevlp00

asked on

JFrame/JDialog Browser problem

We're developming a Java applet which uses swing components.  Here's the basic gist of how it works.  When the applets starts, it generates a JFrame which basically displays online database information.  The JFrame should work in theory like this:  when the default close operation is called (x box in the upper right corner of the frame is clicked) a JDialog box appears and asks for confirmation.  If "yes" is clicked, both frames should close.

In reality - when the default close operation is called the JDialog box appears, however when "yes" is clicked the Dialog box disappears and then reappears a few seconds later as well as the main frame.  We can't get either to disappear.  This only occurs when the applet is run under a browser.  It does not happen when run under Visual Age for Java.  Anybody have any ideas what the problem is and how it could be fixed?

Thanks.  
Avatar of heyhey_
heyhey_

post your code (the problem is in YOUR code :)
Avatar of CatDevlp00

ASKER

Sorry, there's way too much code handling these events for it to be posted here at this time.  I was wondering if there was a JFrame - browser bug.  If not, I'll see if I can whittle the code down to a managable portion to be posted here.  Thanks.
JFrame is just java.awt.Frame + some additional code (double buffering etc.)
all you have to do is capture the WindowClosing event and hide your Frame.

you may want to add some System.out.println() + Thread.dumpStack() to Frame's show() / hide() & setVisible() methods, so that you can track who and when calls these methods)

Make a small example that reproduces the bug. Just strip down all unrelated to the frame stuff, run it, then post it here.

I could only guess, but may b you do initialization of your frame in the start() method, and start is called quite often from the browser. move all GUI initializations to the init() of the applet.

Cheers,
  Nik
ASKER CERTIFIED SOLUTION
Avatar of 108093233315
108093233315

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Adjusted points to 75