| 
 | Java™ Platform Standard Ed. 6 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object extended by java.awt.Component extended by java.awt.Container extended by java.awt.Window extended by java.awt.Dialog
public class Dialog
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 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 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.
WindowEvent, 
Window.addWindowListener(java.awt.event.WindowListener), 
Serialized Form
| Nested Class Summary | |
|---|---|
| protected class | Dialog.AccessibleAWTDialogThis class implements accessibility support for the Dialogclass. | 
| static class | Dialog.ModalExclusionTypeAny top-level window can be marked not to be blocked by modal dialogs. | 
| static class | Dialog.ModalityTypeModal 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_TYPEDefault modality type for modal dialogs. | 
| Fields inherited from class java.awt.Component | 
|---|
| BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT | 
| Fields inherited from interface java.awt.image.ImageObserver | 
|---|
| ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH | 
| Constructor Summary | |
|---|---|
| Dialog(Dialog owner)Constructs an initially invisible, modeless Dialogwith
 the specified ownerDialogand an empty title. | |
| Dialog(Dialog owner,
 String title)Constructs an initially invisible, modeless Dialogwith the specified ownerDialogand title. | |
| Dialog(Dialog owner,
 String title,
 boolean modal)Constructs an initially invisible Dialogwith the
 specified ownerDialog, title, and modality. | |
| Dialog(Dialog owner,
 String title,
 boolean modal,
 GraphicsConfiguration gc)Constructs an initially invisible Dialogwith the
 specified ownerDialog, title, modality andGraphicsConfiguration. | |
| Dialog(Frame owner)Constructs an initially invisible, modeless Dialogwith
 the specified ownerFrameand an empty title. | |
| Dialog(Frame owner,
 boolean modal)Constructs an initially invisible Dialogwith the specified
 ownerFrameand modality and an empty title. | |
| Dialog(Frame owner,
 String title)Constructs an initially invisible, modeless Dialogwith
 the specified ownerFrameand title. | |
| Dialog(Frame owner,
 String title,
 boolean modal)Constructs an initially invisible Dialogwith the
 specified ownerFrame, title and modality. | |
| Dialog(Frame owner,
 String title,
 boolean modal,
 GraphicsConfiguration gc)Constructs an initially invisible Dialogwith the specified ownerFrame, title, modality, andGraphicsConfiguration. | |
| Dialog(Window owner)Constructs an initially invisible, modeless Dialogwith the
 specified ownerWindowand an empty title. | |
| Dialog(Window owner,
 Dialog.ModalityType modalityType)Constructs an initially invisible Dialogwith the
 specified ownerWindowand modality and an empty title. | |
| Dialog(Window owner,
 String title)Constructs an initially invisible, modeless Dialogwith
 the specified ownerWindowand title. | |
| Dialog(Window owner,
 String title,
 Dialog.ModalityType modalityType)Constructs an initially invisible Dialogwith the
 specified ownerWindow, title and modality. | |
| Dialog(Window owner,
 String title,
 Dialog.ModalityType modalityType,
 GraphicsConfiguration gc)Constructs an initially invisible Dialogwith the
 specified ownerWindow, title, modality andGraphicsConfiguration. | |
| Method Summary | |
|---|---|
|  void | addNotify()Makes this Dialog displayable by connecting it to a native screen resource. | 
|  AccessibleContext | getAccessibleContext()Gets the AccessibleContext associated with this Dialog. | 
|  Dialog.ModalityType | getModalityType()Returns the modality type of this dialog. | 
|  String | getTitle()Gets the title of the dialog. | 
|  void | hide()Deprecated. As of JDK version 1.5, replaced by setVisible(boolean). | 
|  boolean | isModal()Indicates whether the dialog is modal. | 
|  boolean | isResizable()Indicates whether this dialog is resizable by the user. | 
|  boolean | isUndecorated()Indicates whether this dialog is undecorated. | 
| protected String | paramString()Returns a string representing the state of this dialog. | 
|  void | setModal(boolean modal)Specifies whether this dialog should be modal. | 
|  void | setModalityType(Dialog.ModalityType type)Sets the modality type for this dialog. | 
|  void | setResizable(boolean resizable)Sets whether this dialog is resizable by the user. | 
|  void | setTitle(String title)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 Dialogdepending on the value of parameterb. | 
|  void | show()Deprecated. As of JDK version 1.5, replaced by setVisible(boolean). | 
|  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, 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).
Dialog.ModalityType, 
setModal(boolean)| Constructor Detail | 
|---|
public 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 owner
IllegalArgumentException - if the owner's
 GraphicsConfiguration is not from a screen device
HeadlessException - when
 GraphicsEnvironment.isHeadless() returns trueGraphicsEnvironment.isHeadless(), 
Component.setSize(int, int), 
Component.setVisible(boolean)public 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
IllegalArgumentException - if the owner's
 GraphicsConfiguration is not from a screen device
HeadlessException - when
 GraphicsEnvironment.isHeadless() returns trueDialog.ModalityType, 
Dialog.ModalityType.MODELESS, 
DEFAULT_MODALITY_TYPE, 
setModal(boolean), 
setModalityType(java.awt.Dialog.ModalityType), 
GraphicsEnvironment.isHeadless()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 title
IllegalArgumentException - if the owner's
 GraphicsConfiguration is not from a screen device
HeadlessException - when
 GraphicsEnvironment.isHeadless() returns trueGraphicsEnvironment.isHeadless(), 
Component.setSize(int, int), 
Component.setVisible(boolean)public 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
IllegalArgumentException - if the owner's
 GraphicsConfiguration is not from a screen device
HeadlessException - when
 GraphicsEnvironment.isHeadless() returns trueDialog.ModalityType, 
Dialog.ModalityType.MODELESS, 
DEFAULT_MODALITY_TYPE, 
setModal(boolean), 
setModalityType(java.awt.Dialog.ModalityType), 
GraphicsEnvironment.isHeadless(), 
Component.setSize(int, int), 
Component.setVisible(boolean)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_TYPEgc - the GraphicsConfiguration of the target screen device;
 if null, the default system GraphicsConfiguration
 is assumed
IllegalArgumentException - if gc
 is not from a screen device
HeadlessException - when
 GraphicsEnvironment.isHeadless() returns trueDialog.ModalityType, 
Dialog.ModalityType.MODELESS, 
DEFAULT_MODALITY_TYPE, 
setModal(boolean), 
setModalityType(java.awt.Dialog.ModalityType), 
GraphicsEnvironment.isHeadless(), 
Component.setSize(int, int), 
Component.setVisible(boolean)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 owner
IllegalArgumentException - if the owner's
 GraphicsConfiguration is not from a screen device
HeadlessException - when
 GraphicsEnvironment.isHeadless() returns trueGraphicsEnvironment.isHeadless()public 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 title
IllegalArgumentException - if the owner's
 GraphicsConfiguration is not from a screen device
HeadlessException - when
 GraphicsEnvironment.isHeadless() returns trueGraphicsEnvironment.isHeadless()public 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
IllegalArgumentException - if the owner's
 GraphicsConfiguration is not from a screen device
HeadlessException - when
 GraphicsEnvironment.isHeadless() returns trueDialog.ModalityType, 
Dialog.ModalityType.MODELESS, 
DEFAULT_MODALITY_TYPE, 
setModal(boolean), 
setModalityType(java.awt.Dialog.ModalityType), 
GraphicsEnvironment.isHeadless()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_TYPEgc - the GraphicsConfiguration of the target screen device;
 if null, the default system GraphicsConfiguration
 is assumed
IllegalArgumentException - if gc
 is not from a screen device
HeadlessException - when
 GraphicsEnvironment.isHeadless() returns trueDialog.ModalityType, 
Dialog.ModalityType.MODELESS, 
DEFAULT_MODALITY_TYPE, 
setModal(boolean), 
setModalityType(java.awt.Dialog.ModalityType), 
GraphicsEnvironment.isHeadless(), 
Component.setSize(int, int), 
Component.setVisible(boolean)public 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
 Dialog, Frame, any
 of their descendents or null
IllegalArgumentException - if the owner
 is not an instance of Dialog or Frame
IllegalArgumentException - if the owner's
 GraphicsConfiguration is not from a screen device
HeadlessException - when
 GraphicsEnvironment.isHeadless() returns trueGraphicsEnvironment.isHeadless()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
 Dialog, Frame, any
 of their descendents or nulltitle - the title of the dialog or null if this dialog
 has no title
IllegalArgumentException - if the owner
 is not an instance of Dialog or Frame
IllegalArgumentException - if the owner's
 GraphicsConfiguration is not from a screen device
HeadlessException - when
 GraphicsEnvironment.isHeadless() returns trueGraphicsEnvironment.isHeadless()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
 Dialog, Frame, any
 of their descendents or nullmodalityType - specifies whether dialog blocks input to other
 windows when shown. null value and unsupported modality
 types are equivalent to MODELESS
IllegalArgumentException - if the owner
 is not an instance of Dialog or Frame
IllegalArgumentException - if the owner's
 GraphicsConfiguration is not from a screen device
HeadlessException - when
 GraphicsEnvironment.isHeadless() returns true
SecurityException - if the calling thread does not have permission
 to create modal dialogs with the given modalityTypeDialog.ModalityType, 
setModal(boolean), 
setModalityType(java.awt.Dialog.ModalityType), 
GraphicsEnvironment.isHeadless(), 
Toolkit.isModalityTypeSupported(java.awt.Dialog.ModalityType)public 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
 Dialog, Frame, any
 of their descendents or nulltitle - 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
IllegalArgumentException - if the owner
 is not an instance of Dialog or Frame
IllegalArgumentException - if the owner's
 GraphicsConfiguration is not from a screen device
HeadlessException - when
 GraphicsEnvironment.isHeadless() returns true
SecurityException - if the calling thread does not have permission
 to create modal dialogs with the given modalityTypeDialog.ModalityType, 
setModal(boolean), 
setModalityType(java.awt.Dialog.ModalityType), 
GraphicsEnvironment.isHeadless(), 
Toolkit.isModalityTypeSupported(java.awt.Dialog.ModalityType)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
 Dialog, Frame, any
 of their descendents or nulltitle - 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 MODELESSgc - the GraphicsConfiguration of the target screen device;
 if null, the default system GraphicsConfiguration
 is assumed
IllegalArgumentException - if the owner
 is not an instance of Dialog or Frame
IllegalArgumentException - if gc
 is not from a screen device
HeadlessException - when
 GraphicsEnvironment.isHeadless() returns true
SecurityException - if the calling thread does not have permission
 to create modal dialogs with the given modalityTypeDialog.ModalityType, 
setModal(boolean), 
setModalityType(java.awt.Dialog.ModalityType), 
GraphicsEnvironment.isHeadless(), 
Toolkit.isModalityTypeSupported(java.awt.Dialog.ModalityType)| Method Detail | 
|---|
public void addNotify()
public boolean isModal()
 This method is obsolete and is kept for backwards compatiblity only.
 Use getModalityType() instead.
true if this dialog window is modal;
 false otherwiseDEFAULT_MODALITY_TYPE, 
Dialog.ModalityType.MODELESS, 
setModal(boolean), 
getModalityType(), 
setModalityType(java.awt.Dialog.ModalityType)public void setModal(boolean modal)
 This method is obsolete and is kept for backwards compatibility only.
 Use 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)DEFAULT_MODALITY_TYPE, 
Dialog.ModalityType.MODELESS, 
isModal(), 
getModalityType(), 
setModalityType(java.awt.Dialog.ModalityType)public Dialog.ModalityType getModalityType()
setModalityType(java.awt.Dialog.ModalityType)public void setModalityType(Dialog.ModalityType type)
ModalityType for possible modality types.
 
 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
SecurityException - if the calling thread does not have permission
 to create modal dialogs with the given modalityTypegetModalityType(), 
Toolkit.isModalityTypeSupported(java.awt.Dialog.ModalityType)public String getTitle()
null.setTitle(java.lang.String)public void setTitle(String title)
title - the title displayed in the dialog's border;
 a null value results in an empty titlegetTitle()public void setVisible(boolean b)
Dialog depending on the value of parameter
 b.
setVisible in class Windowb - if true, makes the Dialog visible, 
 otherwise hides the 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 false, hides the Dialog and then causes setVisible(true)
 to return if it is currently blocked.
 Notes for modal dialogs.
setVisible(true): If the dialog is not already
 visible, this call will not return until the dialog is
 hidden by calling setVisible(false) or
 dispose.
 setVisible(false): Hides the dialog and then
 returns on setVisible(true) if it is currently blocked.
 Window.setVisible(boolean), 
Window.dispose(), 
Component.isDisplayable(), 
Component.validate(), 
isModal()@Deprecated public void show()
setVisible(boolean).
Dialog visible. 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 the dialog is already visible, this will bring the dialog 
 to the front.
 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.
@Deprecated public void hide()
setVisible(boolean).
show to return if it is currently
 blocked.
public void toBack()
Places this Window at the bottom of the stacking order and shows it behind any other Windows in this VM. No action will take place is this Window is not visible. Some platforms do not allow Windows which are owned by other Windows to appear below their owners. Every attempt will be made to move this Window as low as possible in the stacking order; however, developers should not assume that this method will move this Window below all other windows in every situation.
Because of variations in native windowing systems, no guarantees about changes to the focused and active Windows can be made. Developers must never assume that this Window is no longer the focused or active Window until this Window receives a WINDOW_LOST_FOCUS or WINDOW_DEACTIVATED event. On platforms where the top-most window is the focused window, this method will probably cause this Window to lose focus. In that case, the next highest, focusable Window in this VM will receive focus. On platforms where the stacking order does not typically affect the focused window, this method will probably leave the focused and active Windows unchanged.
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.
Window.toBack()public boolean isResizable()
true if the user can resize the dialog;
 false otherwise.setResizable(boolean)public void setResizable(boolean resizable)
resizable - true if the user can
 resize this dialog; false otherwise.isResizable()public void setUndecorated(boolean undecorated)
undecorated - true if no dialog decorations are
 to be enabled;
 false if dialog decorations are to be enabled.
IllegalComponentStateExceptionisUndecorated(), 
Component.isDisplayable()public boolean isUndecorated()
true if dialog is undecorated;
 false otherwise.setUndecorated(boolean)protected String paramString()
null.
paramString in class Containerpublic AccessibleContext getAccessibleContext()
getAccessibleContext in interface AccessiblegetAccessibleContext in class Window| 
 | Java™ Platform Standard Ed. 6 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Copyright © 1993, 2015, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
Scripting on this page tracks web page traffic, but does not change the content in any way.