Solved

JFrame/JDialog Browser problem

Posted on 2000-02-17
6
952 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
looking for unix program to search some keywords in side EAR WAR and JAR files 10 79
Java Jpanels and Jframe 8 28
maven project error 5 44
github account with ecipse 1 42
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 …

943 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

15 Experts available now in Live!

Get 1:1 Help Now