java.awt

Class Dialog

public class Dialog extends Window

Dialog provides a top-level window normally used to receive user input in applications.

A dialog always has another top-level window as owner and is only visible if this owner is visible to the user. The default layout of dialogs is the BorderLayout. Dialogs can be modal (blocks user input to other components) or non-modal (user input in other components are allowed).

Nested Class Summary
protected classDialog.AccessibleAWTDialog
Accessibility support for Dialog.
Constructor Summary
Dialog(Frame parent)
Initializes a new instance of Dialog with the specified parent, that is resizable and not modal, and which has no title.
Dialog(Frame parent, boolean modal)
Initializes a new instance of Dialog with the specified parent and modality, that is resizable and which has no title.
Dialog(Frame parent, String title)
Initializes a new instance of Dialog with the specified parent, that is resizable and not modal, and which has the specified title.
Dialog(Frame parent, String title, boolean modal)
Initializes a new instance of Dialog with the specified, parent, title, and modality, that is resizable.
Dialog(Frame parent, String title, boolean modal, GraphicsConfiguration gc)
Initializes a new instance of Dialog with the specified, parent, title, modality and GraphicsConfiguration, that is resizable.
Dialog(Dialog owner)
Initializes a new instance of Dialog with the specified, parent, that is resizable.
Dialog(Dialog owner, String title)
Initializes a new instance of Dialog with the specified, parent and title, that is resizable.
Dialog(Dialog owner, String title, boolean modal)
Initializes a new instance of Dialog with the specified, parent, title and modality, that is resizable.
Dialog(Dialog parent, String title, boolean modal, GraphicsConfiguration gc)
Initializes a new instance of Dialog with the specified, parent, title, modality and GraphicsConfiguration, that is resizable.
Method Summary
voidaddNotify()
Creates this object's native peer.
voiddispose()
Disposes the Dialog and then causes show() to return if it is currently blocked.
AccessibleContextgetAccessibleContext()
Gets the AccessibleContext associated with this Dialog.
StringgetTitle()
Returns the title of this dialog box.
voidhide()
Hides the Dialog and then causes show() to return if it is currently blocked.
booleanisModal()
Tests whether or not this dialog box is modal.
booleanisResizable()
Tests whether or not this dialog box is resizable.
booleanisUndecorated()
Returns whether this frame is undecorated or not.
protected StringparamString()
Returns a debugging string for this component.
voidsetModal(boolean modal)
Changes the modality of this dialog box.
voidsetResizable(boolean resizable)
Changes the resizability of this dialog box.
voidsetTitle(String title)
Sets the title of this dialog box to the specified string.
voidsetUndecorated(boolean undecorated)
Disables or enables decorations for this frame.
voidshow()
Makes this dialog visible and brings it to the front.

Constructor Detail

Dialog

public Dialog(Frame parent)
Initializes a new instance of Dialog with the specified parent, that is resizable and not modal, and which has no title.

Parameters: parent The parent frame of this dialog box.

Throws: IllegalArgumentException If the owner's GraphicsConfiguration is not from a screen device, or if owner is null. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true.

Dialog

public Dialog(Frame parent, boolean modal)
Initializes a new instance of Dialog with the specified parent and modality, that is resizable and which has no title.

Parameters: parent The parent frame of this dialog box. modal true if this dialog box is modal, false otherwise.

Throws: IllegalArgumentException If the owner's GraphicsConfiguration is not from a screen device, or if owner is null. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true.

Dialog

public Dialog(Frame parent, String title)
Initializes a new instance of Dialog with the specified parent, that is resizable and not modal, and which has the specified title.

Parameters: parent The parent frame of this dialog box. title The title string for this dialog box.

Throws: IllegalArgumentException If the owner's GraphicsConfiguration is not from a screen device, or if owner is null. This exceptionnis always thrown when GraphicsEnvironment.isHeadless() returns true.

Dialog

public Dialog(Frame parent, String title, boolean modal)
Initializes a new instance of Dialog with the specified, parent, title, and modality, that is resizable.

Parameters: parent The parent frame of this dialog box. title The title string for this dialog box. modal true if this dialog box is modal, false otherwise.

Throws: IllegalArgumentException If owner is null or GraphicsEnvironment.isHeadless() returns true.

Dialog

public Dialog(Frame parent, String title, boolean modal, GraphicsConfiguration gc)
Initializes a new instance of Dialog with the specified, parent, title, modality and GraphicsConfiguration, that is resizable.

Parameters: parent The parent frame of this dialog box. title The title string for this dialog box. modal true if this dialog box is modal, false otherwise. gc The GraphicsConfiguration object to use. If null the GraphicsConfiguration of the target frame is used.

Throws: IllegalArgumentException If owner is null, the GraphicsConfiguration is not a screen device or GraphicsEnvironment.isHeadless() returns true.

Since: 1.4

Dialog

public Dialog(Dialog owner)
Initializes a new instance of Dialog with the specified, parent, that is resizable.

Parameters: owner The parent frame of this dialog box.

Throws: IllegalArgumentException If parent is null. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true.

Since: 1.2

Dialog

public Dialog(Dialog owner, String title)
Initializes a new instance of Dialog with the specified, parent and title, that is resizable.

Parameters: owner The parent frame of this dialog box. title The title string for this dialog box.

Throws: IllegalArgumentException If parent is null. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true.

Since: 1.2

Dialog

public Dialog(Dialog owner, String title, boolean modal)
Initializes a new instance of Dialog with the specified, parent, title and modality, that is resizable.

Parameters: owner The parent frame of this dialog box. title The title string for this dialog box. modal true if this dialog box is modal, false otherwise.

Throws: IllegalArgumentException If parent is null. This exception is always thrown when GraphicsEnvironment.isHeadless() returns true.

Since: 1.2

Dialog

public Dialog(Dialog parent, String title, boolean modal, GraphicsConfiguration gc)
Initializes a new instance of Dialog with the specified, parent, title, modality and GraphicsConfiguration, that is resizable.

Parameters: parent The parent frame of this dialog box. title The title string for this dialog box. modal true if this dialog box is modal, false otherwise. gc The GraphicsConfiguration object to use. If null the GraphicsConfiguration of the target frame is used.

Throws: IllegalArgumentException If parent is null, the GraphicsConfiguration is not a screen device or GraphicsEnvironment.isHeadless() returns true.

Since: 1.4

Method Detail

addNotify

public void addNotify()
Creates this object's native peer.

dispose

public void dispose()
Disposes the Dialog and then causes show() to return if it is currently blocked.

getAccessibleContext

public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this Dialog. The context is created, if necessary.

Returns: the associated context

getTitle

public String getTitle()
Returns the title of this dialog box.

Returns: The title of this dialog box.

hide

public void hide()

Deprecated: Use {@link Component#setVisible(boolean)} instead.

Hides the Dialog and then causes show() to return if it is currently blocked.

isModal

public boolean isModal()
Tests whether or not this dialog box is modal.

Returns: true if this dialog box is modal, false otherwise.

isResizable

public boolean isResizable()
Tests whether or not this dialog box is resizable.

Returns: true if this dialog is resizable, false otherwise.

isUndecorated

public boolean isUndecorated()
Returns whether this frame is undecorated or not.

Returns: true if this dialog is undecorated, false otherwise.

Since: 1.4

paramString

protected String paramString()
Returns a debugging string for this component.

Returns: A debugging string for this component.

setModal

public void setModal(boolean modal)
Changes the modality of this dialog box. This can only be done before the peer is created.

Parameters: modal true to make this dialog box modal, false to make it non-modal.

setResizable

public void setResizable(boolean resizable)
Changes the resizability of this dialog box.

Parameters: resizable true to make this dialog resizable, false to make it non-resizable.

setTitle

public void setTitle(String title)
Sets the title of this dialog box to the specified string.

Parameters: title the new title. If null an empty title will be set.

setUndecorated

public void setUndecorated(boolean undecorated)
Disables or enables decorations for this frame. This method can only be called while the frame is not displayable.

Parameters: undecorated true to disable dialog decorations, false otherwise.

Throws: IllegalComponentStateException If this frame is displayable.

Since: 1.4

show

public void show()

Deprecated: Use {@link Component#setVisible(boolean)} instead.

Makes this dialog visible and brings it to the front. If the dialog is modal and is not already visible, this call will not return until the dialog is hidden by someone calling hide or dispose. If this is the event dispatching thread we must ensure that another event thread runs while the one which invoked this method is blocked.