Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making an Applet the parent of a Dialog ?????

Status
Not open for further replies.

Watts

Programmer
Jan 18, 2001
80
US
How do make the parent of the Dialog object an Applet? My applet runs in a browser and I want all input to that applet blocked until the Dialog is dealt with.

The Dialog constructor only accepts a Frame class as its parent. Since my GUI is running in an Applet, I don't have a Frame to assign as the parent of my Dialog. This is a such a dilemma! Please help...
 
I found out how to do this, with a call to getParent() but even though the Dialog box is always on top, the applet still allows input from the user in the background.

Is there any way to force the mouse to stay inside the dialog window until it is closed? Please let me know...
 
Just to let everyone know, you cannot create a Modal Dialog within an applet that is Modal with respect to the IE window that contains the Applet itself. You have to create your own window.

I am currently working around this bug in the way IE handle Java Dialog class by using a simple Panel that covers my existing GUI.
 
Hm.. this could be quite disastrous since your JDialog would be on top of your browser at all times... anyway you can take a look at the example I have done:-

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class dialogDemo extends JApplet implements ActionListener
{
public void init()
{
getContentPane().setLayout(null);
setSize(200,200);

JLabel lbl = new JLabel("hello world");
lbl.setBounds(new Rectangle(10,10,200,20));

JButton b = new JButton("Click");
b.setBounds(new Rectangle(10,30,75,20));
b.addActionListener(this);

getContentPane().add(lbl, null);
getContentPane().add(b, null);

JDialog d = new JDialog();
d.setModal(true);
d.show();
}

public void actionPerformed(ActionEvent e)
{
JOptionPane.showMessageDialog(null,new String("Hello World"));
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top