?
Solved

JFrame/JDialog Browser problem

Posted on 2000-02-17
6
Medium Priority
?
959 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

764 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