Solved

Problem with JApplet and Modal JDialog

Posted on 2001-09-05
3
700 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

758 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

18 Experts available now in Live!

Get 1:1 Help Now