Solved

JFrame/JDialog Browser problem

Posted on 2000-02-17
6
951 Views
Last Modified: 2013-11-23
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.  
0
Comment
Question by:CatDevlp00
6 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 2532580
post your code (the problem is in YOUR code :)
0
 

Author Comment

by:CatDevlp00
ID: 2532679
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.
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 2532745
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)

0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 8

Expert Comment

by:diakov
ID: 2534014
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
0
 

Accepted Solution

by:
108093233315 earned 75 total points
ID: 2534060
1.) Call the following method of your JFrame:

myFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);


2.) Use

JOptionPane.showConfirmDialog(Component parentComponent, Object message, String title, int optionType)

instead of JDialog.
0
 

Author Comment

by:CatDevlp00
ID: 2542625
Adjusted points to 75
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now