Java Reference
In-Depth Information
public JDialog(Dialog owner, boolean modal)
JDialog dialog = new JDialog(anotherDialog, true);
public JDialog(Dialog owner, String title)
JDialog dialog = new JDialog(anotherDialog, "Hello");
public JDialog(Dialog owner, String title, boolean modal)
JDialog dialog = new JDialog(anotherDialog, "Hello", true);
public JDialog(Dialog owner, String title, boolean modal, GraphicsConfiguration gc)
GraphicsConfiguration gc = ...;
JDialog dialog = new JDialog(anotherDialog, "Hello", true, gc);
public JDialog(Frame owner)
JDialog dialog = new JDialog(aFrame);
public JDialog(Frame owner, String windowTitle)
JDialog dialog = new JDialog(aFrame, "Hello");
public JDialog(Frame owner, boolean modal)
JDialog dialog = new JDialog(aFrame, false);
public JDialog(Frame owner, String title, boolean modal)
JDialog dialog = new JDialog(aFrame, "Hello", true);
public JDialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc)
GraphicsConfiguration gc = ...;
JDialog dialog = new JDialog(aFrame, "Hello", true, gc);
■
Note
Instead of manually creating a
JDialog
and populating it, you may find yourself having
JOptionPane
automatically create and fill the
JDialog
for you. You'll explore the
JOptionPane
component in Chapter 9.
Each constructor allows you to customize the dialog owner, the window title, and the
modality of the pop-up. When a
JDialog
is modal, it blocks input to the owner and the rest of
the application. When a
JDialog
is nonmodal, it allows a user to interact with the
JDialog
as
well as the rest of your application.
■
Caution
For modality to work properly among the different Java versions, avoid mixing heavyweight AWT
components with lightweight Swing components in a
JDialog
.