Solved

Problem with JApplet and Modal JDialog

Posted on 2001-09-05
3
703 Views
Last Modified: 2008-02-01
Hi All,

I have problem with modal dialogs in a JApplet. The dialog
loose focus when I click on the parent applet. Then the dialog disappear behind Internet Explorer.

How to sovle this problem?

Thanks
nhp
0
Comment
Question by:nhphu
3 Comments
 
LVL 9

Expert Comment

by:Ovi
ID: 6456677
You can't, the JDialog event if is modal is not a system modal dialog, but a Java modal dialog. So the flag modal will not work "outside" a Java enviroinment.
0
 
LVL 16

Expert Comment

by:Valeri
ID: 6456913
Put this line in the constructor of your class that extends JDialog :

super(JOptionPane.getFrameForComponent(theparentComponent), "Title", true);

I hope it will help you.
best regards,
Valeri
0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 10 total points
ID: 6457194
you have to use the appropriate parent Frame

try something like this

Frame modalFrame;
Component c = applet;
while ((c != null) && !(c instanceof Frame)) c = c.getParent();

if (c != null)
  modalFrame = (Frame)c;
else
  modalFrame = new Frame("dummy modal");
 
 
JDialog dialog = new JDialog(modalFrame, ...);
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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:

808 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