JDialog : Java Glossary
©1996-2017 2006-02-02 Roedy Green of Canadian Mind Products
JDialogs are a type of Window
that pop up over a parent JFrame, usually to ask the user
to confirm something or display an About box. JDialogs can
be modal or non-modal. Modal
JDialogs monopolise the user’s attention, preventing
him from clicking anywhere but in the jdialog box.
For simple questions, you can use JOptionPane.showInputDialog which comes in two versions, one that
just prompts for a String and one that selects an item from
Dialog is the AWT (Advanced Windowing Toolkit)
equivalent of JDialog.
- If JDialogs fail to paint anything, it could be
because you forgot to do a setSize, validate(), or setVisible( true ).
does not work. Use jdialog.getContentPane().setBackground(
aColour ) and jdialog.getContentPane().add( child );
- JDialog constructors want a Frame/JFrame as parent. Unfortunately, JApplet is an Applet, which is a
Panel, not a Frame. This
can be a problem. There are a number of ways to handle it:
- In Java version 1.4 or later you can pass
null as the parent Frame. However, this is buggy when the encloding frame in an
- Create a dummy non-displaying JFrame for the
JDialog live in. Keep in mind you will not recover
all the memory unless you explicity dispose the
- Pop up a visible empty JFrame for the
JDialog live in.
- To embed a JDialog in an Applet, you must chase the
chain until you find an instanceof Frame. Use the following getParentFrame method to get a handle on the enclosing
The above code is part of the com.mindprod.common18.Misc class.
You can download it
as part of the common18 bundle.
Oracle’s Javadoc on JDialog
class : available: