A Dialog is a top-level window with a title and a border that is typically used to take some form of input from the user. The size of the dialog includes any area designated for the border. The dimensions of the border area can be obtained using the
getInsets
method, however, since these dimensions are platform-dependent, a valid insets value cannot be obtained until the dialog is made displayable by either calling
pack
or
show
. Since the border area is included in the overall size of the dialog, the border effectively obscures a portion of the dialog, constraining the area available for rendering and/or displaying subcomponents to the rectangle which has an upper-left corner location of
(insets.left, insets.top)
, and has a size of
width - (insets.left + insets.right)
by
height - (insets.top + insets.bottom)
.
The default layout for a dialog is BorderLayout
.
A dialog may have its native decorations (i.e. Frame & Titlebar) turned off with setUndecorated
. This can only be done while the dialog is not {@link Component#isDisplayable() displayable}.
A dialog may have another window as its owner when it's constructed. When the owner window of a visible dialog is minimized, the dialog will automatically be hidden from the user. When the owner window is subsequently restored, the dialog is made visible to the user again.
In a multi-screen environment, you can create a Dialog
on a different screen device than its owner. See {@link java.awt.Frame} formore information.
A dialog can be either modeless (the default) or modal. A modal dialog is one which blocks input to some other top-level windows in the application, except for any windows created with the dialog as their owner. See AWT Modality specification for details.
Dialogs are capable of generating the following WindowEvents
: WindowOpened
, WindowClosing
, WindowClosed
, WindowActivated
, WindowDeactivated
, WindowGainedFocus
, WindowLostFocus
.
@see WindowEvent
@see Window#addWindowListener
@version 1.131, 04/13/09
@author Sami Shaio
@author Arthur van Hoff
@since JDK1.0