| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public class Dialog extends Window
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} for
more 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
.
Nested Class Summary | |
---|---|
protected class |
This class implements accessibility support for the Dialog class. |
static enum |
Any top-level window can be marked not to be blocked by modal dialogs. |
static enum |
Modal dialogs block all input to some top-level windows. |
Nested classes/interfaces inherited from class java.awt.Window |
---|
Window.AccessibleAWTWindow |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static Dialog.ModalityType |
DEFAULT_MODALITY_TYPE
Default modality type for modal dialogs. |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Constructor Summary | |
---|---|
Constructs an initially invisible, modeless Dialog with
the specified owner Dialog and an empty title.
|
|
Constructs an initially invisible, modeless Dialog
with the specified owner Dialog and title.
|
|
Constructs an initially invisible Dialog with the
specified owner Dialog , title, and modality.
|
|
Dialog(Dialog owner, String title, boolean modal, GraphicsConfiguration gc) Constructs an initially invisible Dialog with the
specified owner Dialog , title, modality and
GraphicsConfiguration .
|
|
Constructs an initially invisible, modeless Dialog with
the specified owner Frame and an empty title.
|
|
Constructs an initially invisible Dialog with the specified
owner Frame and modality and an empty title.
|
|
Constructs an initially invisible, modeless Dialog with
the specified owner Frame and title.
|
|
Constructs an initially invisible Dialog with the
specified owner Frame , title and modality.
|
|
Dialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc) Constructs an initially invisible Dialog with the specified owner
Frame , title, modality, and GraphicsConfiguration .
|
|
Constructs an initially invisible, modeless Dialog with the
specified owner Window and an empty title.
|
|
Dialog(Window owner, Dialog.ModalityType modalityType) Constructs an initially invisible Dialog with the
specified owner Window and modality and an empty title.
|
|
Constructs an initially invisible, modeless Dialog with
the specified owner Window and title.
|
|
Dialog(Window owner, String title, Dialog.ModalityType modalityType) Constructs an initially invisible Dialog with the
specified owner Window , title and modality.
|
|
Dialog(Window owner, String title, Dialog.ModalityType modalityType, GraphicsConfiguration gc) Constructs an initially invisible Dialog with the
specified owner Window , title, modality and
GraphicsConfiguration .
|
Method Summary | |
---|---|
void |
Makes this Dialog displayable by connecting it to a native screen resource. |
AccessibleContext |
Gets the AccessibleContext associated with this Dialog. |
Dialog.ModalityType |
Returns the modality type of this dialog. |
String |
getTitle() Gets the title of the dialog. |
void |
hide() Hides the Dialog and then causes to return if it is currently blocked. |
boolean |
isModal() Indicates whether the dialog is modal. |
boolean |
Indicates whether this dialog is resizable by the user. |
boolean |
Indicates whether this dialog is undecorated. |
protected String |
Returns a string representing the state of this dialog. |
void |
setModal(boolean modal) Specifies whether this dialog should be modal. |
void |
Sets the modality type for this dialog. |
void |
setResizable(boolean resizable) Sets whether this dialog is resizable by the user. |
void |
Sets the title of the Dialog. |
void |
setUndecorated(boolean undecorated) Disables or enables decorations for this dialog. |
void |
setVisible(boolean b) Shows or hides this depending on the value of parameter . |
void |
show() Makes the visible. |
void |
toBack() If this Window is visible, sends this Window to the back and may cause it to lose focus or activation if it is the focused or active Window. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Dialog.ModalityType DEFAULT_MODALITY_TYPE
APPLICATION_MODAL
. Calling the oldstyle setModal(true)
is equal to setModalityType(DEFAULT_MODALITY_TYPE)
.
Constructor Detail |
---|
public Dialog(Dialog owner)
Dialog
with
the specified owner Dialog
and an empty title.
owner
- the owner of the dialog or null
if this
dialog has no ownerpublic Dialog(Dialog owner, String title)
Dialog
with the specified owner Dialog
and title.
owner
- the owner of the dialog or null
if this
has no ownertitle
- the title of the dialog or null
if this dialog
has no titlepublic Dialog(Dialog owner, String title, boolean modal)
Dialog
with the
specified owner Dialog
, title, and modality.
owner
- the owner of the dialog or null
if this
dialog has no ownertitle
- the title of the dialog or null
if this
dialog has no titlemodal
- specifes whether dialog blocks user input to other top-level
windows when shown. If false
, the dialog is MODELESS
;
if true
, the modality type property is set to
DEFAULT_MODALITY_TYPE
public Dialog(Dialog owner, String title, boolean modal, GraphicsConfiguration gc)
Dialog
with the
specified owner Dialog
, title, modality and
GraphicsConfiguration
.
owner
- the owner of the dialog or null
if this
dialog has no ownertitle
- the title of the dialog or null
if this
dialog has no titlemodal
- specifes whether dialog blocks user input to other top-level
windows when shown. If false
, the dialog is MODELESS
;
if true
, the modality type property is set to
DEFAULT_MODALITY_TYPE
gc
- the GraphicsConfiguration
of the target screen device;
if null
, the default system GraphicsConfiguration
is assumedpublic Dialog(Frame owner)
Dialog
with
the specified owner Frame
and an empty title.
owner
- the owner of the dialog or null
if
this dialog has no ownerpublic Dialog(Frame owner, boolean modal)
Dialog
with the specified
owner Frame
and modality and an empty title.
owner
- the owner of the dialog or null
if
this dialog has no ownermodal
- specifes whether dialog blocks user input to other top-level
windows when shown. If false
, the dialog is MODELESS
;
if true
, the modality type property is set to
DEFAULT_MODALITY_TYPE
public Dialog(Frame owner, String title)
Dialog
with
the specified owner Frame
and title.
owner
- the owner of the dialog or null
if
this dialog has no ownertitle
- the title of the dialog or null
if this dialog
has no titlepublic Dialog(Frame owner, String title, boolean modal)
Dialog
with the
specified owner Frame
, title and modality.
owner
- the owner of the dialog or null
if
this dialog has no ownertitle
- the title of the dialog or null
if this dialog
has no titlemodal
- specifes whether dialog blocks user input to other top-level
windows when shown. If false
, the dialog is MODELESS
;
if true
, the modality type property is set to
DEFAULT_MODALITY_TYPE
public Dialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc)
Dialog
with the specified owner
Frame
, title, modality, and GraphicsConfiguration
.
owner
- the owner of the dialog or null
if this dialog
has no ownertitle
- the title of the dialog or null
if this dialog
has no titlemodal
- specifes whether dialog blocks user input to other top-level
windows when shown. If false
, the dialog is MODELESS
;
if true
, the modality type property is set to
DEFAULT_MODALITY_TYPE
gc
- the GraphicsConfiguration
of the target screen device;
if null
, the default system GraphicsConfiguration
is assumedpublic Dialog(Window owner)
Dialog
with the
specified owner Window
and an empty title.
owner
- the owner of the dialog. The owner must be an instance of
{@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
of their descendents or null
public Dialog(Window owner, Dialog.ModalityType modalityType)
Dialog
with the
specified owner Window
and modality and an empty title.
owner
- the owner of the dialog. The owner must be an instance of
{@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
of their descendents or null
modalityType
- specifies whether dialog blocks input to other
windows when shown. null
value and unsupported modality
types are equivalent to MODELESS
public Dialog(Window owner, String title)
Dialog
with
the specified owner Window
and title.
owner
- the owner of the dialog. The owner must be an instance of
{@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
of their descendents or null
title
- the title of the dialog or null
if this dialog
has no titlepublic Dialog(Window owner, String title, Dialog.ModalityType modalityType)
Dialog
with the
specified owner Window
, title and modality.
owner
- the owner of the dialog. The owner must be an instance of
{@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
of their descendents or null
title
- the title of the dialog or null
if this dialog
has no titlemodalityType
- specifies whether dialog blocks input to other
windows when shown. null
value and unsupported modality
types are equivalent to MODELESS
public Dialog(Window owner, String title, Dialog.ModalityType modalityType, GraphicsConfiguration gc)
Dialog
with the
specified owner Window
, title, modality and
GraphicsConfiguration
.
owner
- the owner of the dialog. The owner must be an instance of
{@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
of their descendents or null
title
- the title of the dialog or null
if this dialog
has no titlemodalityType
- specifies whether dialog blocks input to other
windows when shown. null
value and unsupported modality
types are equivalent to MODELESS
gc
- the GraphicsConfiguration
of the target screen device;
if null
, the default system GraphicsConfiguration
is assumedMethod Detail |
---|
public void addNotify()
addNotify
in class Window
public AccessibleContext getAccessibleContext()
getAccessibleContext
in class Window
public Dialog.ModalityType getModalityType()
public String getTitle()
null
.public void hide()
hide
in class Window
public boolean isModal()
This method is obsolete and is kept for backwards compatiblity only. Use {@link #getModalityType getModalityType()} instead.
true
if this dialog window is modal;
false
otherwisepublic boolean isResizable()
true
if the user can resize the dialog;
false
otherwise.public boolean isUndecorated()
true
if dialog is undecorated;
false
otherwise.protected String paramString()
null
.
paramString
in class Container
public void setModal(boolean modal)
This method is obsolete and is kept for backwards compatibility only. Use {@link #setModalityType setModalityType()} instead.
Note: changing modality of the visible dialog may have no effect until it is hidden and then shown again.
modal
- specifies whether dialog blocks input to other windows
when shown; calling to setModal(true)
is equivalent to
setModalityType(Dialog.DEFAULT_MODALITY_TYPE)
, and
calling to setModal(false)
is equvivalent to
setModalityType(Dialog.ModalityType.MODELESS)
public void setModalityType(Dialog.ModalityType type)
If the given modality type is not supported, MODELESS
is used. You may want to call getModalityType()
after calling
this method to ensure that the modality type has been set.
Note: changing modality of the visible dialog may have no effect until it is hidden and then shown again.
type
- specifies whether dialog blocks input to other
windows when shown. null
value and unsupported modality
types are equivalent to MODELESS
public void setResizable(boolean resizable)
resizable
- true
if the user can
resize this dialog; false
otherwise.public void setTitle(String title)
title
- the title displayed in the dialog's border;
a null value results in an empty titlepublic void setUndecorated(boolean undecorated)
undecorated
- true
if no dialog decorations are
to be enabled;
false
if dialog decorations are to be enabled.public void setVisible(boolean b)
setVisible
in class Window
b
- if {@code true}, makes the {@code Dialog} visible,
otherwise hides the {@code Dialog}.
If the dialog and/or its owner
are not yet displayable, both are made displayable. The
dialog will be validated prior to being made visible.
If {@code false}, hides the {@code Dialog} and then causes {@code setVisible(true)}
to return if it is currently blocked.
Notes for modal dialogs.
public void show()
If the dialog is modal and is not already visible, this call will not return until the dialog is hidden by calling hide or dispose. It is permissible to show modal dialogs from the event dispatching thread because the toolkit will ensure that another event pump runs while the one which invoked this method is blocked.
show
in class Window
public void toBack()
If this dialog is modal and blocks some windows, then all of them are also sent to the back to keep them below the blocking dialog.
toBack
in class Window
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |