- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- java.awt.Window
-
- java.awt.Dialog
-
- All Implemented Interfaces:
- ImageObserver, MenuContainer, Serializable, Accessible
- Direct Known Subclasses:
- FileDialog, JDialog
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 thegetInsets
method, however, since these dimensions are platform-dependent, a valid insets value cannot be obtained until the dialog is made displayable by either callingpack
orshow
. 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 ofwidth - (insets.left + insets.right)
byheight - (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 notdisplayable
.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. SeeFrame
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
.- Since:
- JDK1.0
- See Also:
WindowEvent
,Window.addWindowListener(java.awt.event.WindowListener)
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description protected class
Dialog.AccessibleAWTDialog
This class implements accessibility support for theDialog
class.static class
Dialog.ModalExclusionType
Any top-level window can be marked not to be blocked by modal dialogs.static class
Dialog.ModalityType
Modal dialogs block all input to some top-level windows.-
Nested classes/interfaces inherited from class java.awt.Window
Window.AccessibleAWTWindow, Window.Type
-
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
Fields Modifier and Type Field and Description 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
Constructors Constructor and Description Dialog(Dialog owner)
Constructs an initially invisible, modelessDialog
with the specified ownerDialog
and an empty title.Dialog(Dialog owner, String title)
Constructs an initially invisible, modelessDialog
with the specified ownerDialog
and title.Dialog(Dialog owner, String title, boolean modal)
Constructs an initially invisibleDialog
with the specified ownerDialog
, title, and modality.Dialog(Dialog owner, String title, boolean modal, GraphicsConfiguration gc)
Constructs an initially invisibleDialog
with the specified ownerDialog
, title, modality andGraphicsConfiguration
.Dialog(Frame owner)
Constructs an initially invisible, modelessDialog
with the specified ownerFrame
and an empty title.Dialog(Frame owner, boolean modal)
Constructs an initially invisibleDialog
with the specified ownerFrame
and modality and an empty title.Dialog(Frame owner, String title)
Constructs an initially invisible, modelessDialog
with the specified ownerFrame
and title.Dialog(Frame owner, String title, boolean modal)
Constructs an initially invisibleDialog
with the specified ownerFrame
, title and modality.Dialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc)
Constructs an initially invisibleDialog
with the specified ownerFrame
, title, modality, andGraphicsConfiguration
.Dialog(Window owner)
Constructs an initially invisible, modelessDialog
with the specified ownerWindow
and an empty title.Dialog(Window owner, Dialog.ModalityType modalityType)
Constructs an initially invisibleDialog
with the specified ownerWindow
and modality and an empty title.Dialog(Window owner, String title)
Constructs an initially invisible, modelessDialog
with the specified ownerWindow
and title.Dialog(Window owner, String title, Dialog.ModalityType modalityType)
Constructs an initially invisibleDialog
with the specified ownerWindow
, title and modality.Dialog(Window owner, String title, Dialog.ModalityType modalityType, GraphicsConfiguration gc)
Constructs an initially invisibleDialog
with the specified ownerWindow
, title, modality andGraphicsConfiguration
.
-
Method Summary
Methods Modifier and Type Method and Description 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 bysetVisible(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
setBackground(Color bgColor)
Sets the background color of this window.void
setModal(boolean modal)
Specifies whether this dialog should be modal.void
setModalityType(Dialog.ModalityType type)
Sets the modality type for this dialog.void
setOpacity(float opacity)
Sets the opacity of the window.void
setResizable(boolean resizable)
Sets whether this dialog is resizable by the user.void
setShape(Shape shape)
Sets the shape of the window.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 thisDialog
depending on the value of parameterb
.void
show()
Deprecated.As of JDK version 1.5, replaced bysetVisible(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.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFront
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
DEFAULT_MODALITY_TYPE
public static final Dialog.ModalityType DEFAULT_MODALITY_TYPE
Default modality type for modal dialogs. The default modality type isAPPLICATION_MODAL
. Calling the oldstylesetModal(true)
is equal tosetModalityType(DEFAULT_MODALITY_TYPE)
.- Since:
- 1.6
- See Also:
Dialog.ModalityType
,setModal(boolean)
-
-
Constructor Detail
-
Dialog
public Dialog(Frame owner)
Constructs an initially invisible, modelessDialog
with the specified ownerFrame
and an empty title.- Parameters:
owner
- the owner of the dialog ornull
if this dialog has no owner- Throws:
IllegalArgumentException
- if theowner
'sGraphicsConfiguration
is not from a screen deviceHeadlessException
- whenGraphicsEnvironment.isHeadless()
returnstrue
- See Also:
GraphicsEnvironment.isHeadless()
,Component.setSize(int, int)
,Component.setVisible(boolean)
-
Dialog
public Dialog(Frame owner, boolean modal)
Constructs an initially invisibleDialog
with the specified ownerFrame
and modality and an empty title.- Parameters:
owner
- the owner of the dialog ornull
if this dialog has no ownermodal
- specifes whether dialog blocks user input to other top-level windows when shown. Iffalse
, the dialog isMODELESS
; iftrue
, the modality type property is set toDEFAULT_MODALITY_TYPE
- Throws:
IllegalArgumentException
- if theowner
'sGraphicsConfiguration
is not from a screen deviceHeadlessException
- whenGraphicsEnvironment.isHeadless()
returnstrue
- See Also:
Dialog.ModalityType
,Dialog.ModalityType.MODELESS
,DEFAULT_MODALITY_TYPE
,setModal(boolean)
,setModalityType(java.awt.Dialog.ModalityType)
,GraphicsEnvironment.isHeadless()
-
Dialog
public Dialog(Frame owner, String title)
Constructs an initially invisible, modelessDialog
with the specified ownerFrame
and title.- Parameters:
owner
- the owner of the dialog ornull
if this dialog has no ownertitle
- the title of the dialog ornull
if this dialog has no title- Throws:
IllegalArgumentException
- if theowner
'sGraphicsConfiguration
is not from a screen deviceHeadlessException
- whenGraphicsEnvironment.isHeadless()
returnstrue
- See Also:
GraphicsEnvironment.isHeadless()
,Component.setSize(int, int)
,Component.setVisible(boolean)
-
Dialog
public Dialog(Frame owner, String title, boolean modal)
Constructs an initially invisibleDialog
with the specified ownerFrame
, title and modality.- Parameters:
owner
- the owner of the dialog ornull
if this dialog has no ownertitle
- the title of the dialog ornull
if this dialog has no titlemodal
- specifes whether dialog blocks user input to other top-level windows when shown. Iffalse
, the dialog isMODELESS
; iftrue
, the modality type property is set toDEFAULT_MODALITY_TYPE
- Throws:
IllegalArgumentException
- if theowner
'sGraphicsConfiguration
is not from a screen deviceHeadlessException
- whenGraphicsEnvironment.isHeadless()
returnstrue
- See Also:
Dialog.ModalityType
,Dialog.ModalityType.MODELESS
,DEFAULT_MODALITY_TYPE
,setModal(boolean)
,setModalityType(java.awt.Dialog.ModalityType)
,GraphicsEnvironment.isHeadless()
,Component.setSize(int, int)
,Component.setVisible(boolean)
-
Dialog
public Dialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc)
Constructs an initially invisibleDialog
with the specified ownerFrame
, title, modality, andGraphicsConfiguration
.- Parameters:
owner
- the owner of the dialog ornull
if this dialog has no ownertitle
- the title of the dialog ornull
if this dialog has no titlemodal
- specifes whether dialog blocks user input to other top-level windows when shown. Iffalse
, the dialog isMODELESS
; iftrue
, the modality type property is set toDEFAULT_MODALITY_TYPE
gc
- theGraphicsConfiguration
of the target screen device; ifnull
, the default systemGraphicsConfiguration
is assumed- Throws:
IllegalArgumentException
- ifgc
is not from a screen deviceHeadlessException
- whenGraphicsEnvironment.isHeadless()
returnstrue
- Since:
- 1.4
- See Also:
Dialog.ModalityType
,Dialog.ModalityType.MODELESS
,DEFAULT_MODALITY_TYPE
,setModal(boolean)
,setModalityType(java.awt.Dialog.ModalityType)
,GraphicsEnvironment.isHeadless()
,Component.setSize(int, int)
,Component.setVisible(boolean)
-
Dialog
public Dialog(Dialog owner)
Constructs an initially invisible, modelessDialog
with the specified ownerDialog
and an empty title.- Parameters:
owner
- the owner of the dialog ornull
if this dialog has no owner- Throws:
IllegalArgumentException
- if theowner
'sGraphicsConfiguration
is not from a screen deviceHeadlessException
- whenGraphicsEnvironment.isHeadless()
returnstrue
- Since:
- 1.2
- See Also:
GraphicsEnvironment.isHeadless()
-
Dialog
public Dialog(Dialog owner, String title)
Constructs an initially invisible, modelessDialog
with the specified ownerDialog
and title.- Parameters:
owner
- the owner of the dialog ornull
if this has no ownertitle
- the title of the dialog ornull
if this dialog has no title- Throws:
IllegalArgumentException
- if theowner
'sGraphicsConfiguration
is not from a screen deviceHeadlessException
- whenGraphicsEnvironment.isHeadless()
returnstrue
- Since:
- 1.2
- See Also:
GraphicsEnvironment.isHeadless()
-
Dialog
public Dialog(Dialog owner, String title, boolean modal)
Constructs an initially invisibleDialog
with the specified ownerDialog
, title, and modality.- Parameters:
owner
- the owner of the dialog ornull
if this dialog has no ownertitle
- the title of the dialog ornull
if this dialog has no titlemodal
- specifes whether dialog blocks user input to other top-level windows when shown. Iffalse
, the dialog isMODELESS
; iftrue
, the modality type property is set toDEFAULT_MODALITY_TYPE
- Throws:
IllegalArgumentException
- if theowner
'sGraphicsConfiguration
is not from a screen deviceHeadlessException
- whenGraphicsEnvironment.isHeadless()
returnstrue
- Since:
- 1.2
- See Also:
Dialog.ModalityType
,Dialog.ModalityType.MODELESS
,DEFAULT_MODALITY_TYPE
,setModal(boolean)
,setModalityType(java.awt.Dialog.ModalityType)
,GraphicsEnvironment.isHeadless()
-
Dialog
public Dialog(Dialog owner, String title, boolean modal, GraphicsConfiguration gc)
Constructs an initially invisibleDialog
with the specified ownerDialog
, title, modality andGraphicsConfiguration
.- Parameters:
owner
- the owner of the dialog ornull
if this dialog has no ownertitle
- the title of the dialog ornull
if this dialog has no titlemodal
- specifes whether dialog blocks user input to other top-level windows when shown. Iffalse
, the dialog isMODELESS
; iftrue
, the modality type property is set toDEFAULT_MODALITY_TYPE
gc
- theGraphicsConfiguration
of the target screen device; ifnull
, the default systemGraphicsConfiguration
is assumed- Throws:
IllegalArgumentException
- ifgc
is not from a screen deviceHeadlessException
- whenGraphicsEnvironment.isHeadless()
returnstrue
- Since:
- 1.4
- See Also:
Dialog.ModalityType
,Dialog.ModalityType.MODELESS
,DEFAULT_MODALITY_TYPE
,setModal(boolean)
,setModalityType(java.awt.Dialog.ModalityType)
,GraphicsEnvironment.isHeadless()
,Component.setSize(int, int)
,Component.setVisible(boolean)
-
Dialog
public Dialog(Window owner)
Constructs an initially invisible, modelessDialog
with the specified ownerWindow
and an empty title.- Parameters:
owner
- the owner of the dialog. The owner must be an instance ofDialog
,Frame
, any of their descendents ornull
- Throws:
IllegalArgumentException
- if theowner
is not an instance ofDialog
orFrame
IllegalArgumentException
- if theowner
'sGraphicsConfiguration
is not from a screen deviceHeadlessException
- whenGraphicsEnvironment.isHeadless()
returnstrue
- Since:
- 1.6
- See Also:
GraphicsEnvironment.isHeadless()
-
Dialog
public Dialog(Window owner, String title)
Constructs an initially invisible, modelessDialog
with the specified ownerWindow
and title.- Parameters:
owner
- the owner of the dialog. The owner must be an instance ofDialog
,Frame
, any of their descendents ornull
title
- the title of the dialog ornull
if this dialog has no title- Throws:
IllegalArgumentException
- if theowner
is not an instance ofDialog
orFrame
IllegalArgumentException
- if theowner
'sGraphicsConfiguration
is not from a screen deviceHeadlessException
- whenGraphicsEnvironment.isHeadless()
returnstrue
- Since:
- 1.6
- See Also:
GraphicsEnvironment.isHeadless()
-
Dialog
public Dialog(Window owner, Dialog.ModalityType modalityType)
Constructs an initially invisibleDialog
with the specified ownerWindow
and modality and an empty title.- Parameters:
owner
- the owner of the dialog. The owner must be an instance ofDialog
,Frame
, any of their descendents ornull
modalityType
- specifies whether dialog blocks input to other windows when shown.null
value and unsupported modality types are equivalent toMODELESS
- Throws:
IllegalArgumentException
- if theowner
is not an instance ofDialog
orFrame
IllegalArgumentException
- if theowner
'sGraphicsConfiguration
is not from a screen deviceHeadlessException
- whenGraphicsEnvironment.isHeadless()
returnstrue
SecurityException
- if the calling thread does not have permission to create modal dialogs with the givenmodalityType
- Since:
- 1.6
- See Also:
Dialog.ModalityType
,setModal(boolean)
,setModalityType(java.awt.Dialog.ModalityType)
,GraphicsEnvironment.isHeadless()
,Toolkit.isModalityTypeSupported(java.awt.Dialog.ModalityType)
-
Dialog
public Dialog(Window owner, String title, Dialog.ModalityType modalityType)
Constructs an initially invisibleDialog
with the specified ownerWindow
, title and modality.- Parameters:
owner
- the owner of the dialog. The owner must be an instance ofDialog
,Frame
, any of their descendents ornull
title
- the title of the dialog ornull
if this dialog has no titlemodalityType
- specifies whether dialog blocks input to other windows when shown.null
value and unsupported modality types are equivalent toMODELESS
- Throws:
IllegalArgumentException
- if theowner
is not an instance ofDialog
orFrame
IllegalArgumentException
- if theowner
'sGraphicsConfiguration
is not from a screen deviceHeadlessException
- whenGraphicsEnvironment.isHeadless()
returnstrue
SecurityException
- if the calling thread does not have permission to create modal dialogs with the givenmodalityType
- Since:
- 1.6
- See Also:
Dialog.ModalityType
,setModal(boolean)
,setModalityType(java.awt.Dialog.ModalityType)
,GraphicsEnvironment.isHeadless()
,Toolkit.isModalityTypeSupported(java.awt.Dialog.ModalityType)
-
Dialog
public Dialog(Window owner, String title, Dialog.ModalityType modalityType, GraphicsConfiguration gc)
Constructs an initially invisibleDialog
with the specified ownerWindow
, title, modality andGraphicsConfiguration
.- Parameters:
owner
- the owner of the dialog. The owner must be an instance ofDialog
,Frame
, any of their descendents ornull
title
- the title of the dialog ornull
if this dialog has no titlemodalityType
- specifies whether dialog blocks input to other windows when shown.null
value and unsupported modality types are equivalent toMODELESS
gc
- theGraphicsConfiguration
of the target screen device; ifnull
, the default systemGraphicsConfiguration
is assumed- Throws:
IllegalArgumentException
- if theowner
is not an instance ofDialog
orFrame
IllegalArgumentException
- ifgc
is not from a screen deviceHeadlessException
- whenGraphicsEnvironment.isHeadless()
returnstrue
SecurityException
- if the calling thread does not have permission to create modal dialogs with the givenmodalityType
- Since:
- 1.6
- See Also:
Dialog.ModalityType
,setModal(boolean)
,setModalityType(java.awt.Dialog.ModalityType)
,GraphicsEnvironment.isHeadless()
,Toolkit.isModalityTypeSupported(java.awt.Dialog.ModalityType)
-
-
Method Detail
-
addNotify
public void addNotify()
Makes this Dialog displayable by connecting it to a native screen resource. Making a dialog displayable will cause any of its children to be made displayable. This method is called internally by the toolkit and should not be called directly by programs.- Overrides:
addNotify
in classWindow
- See Also:
Component.isDisplayable()
,Window.removeNotify()
-
isModal
public boolean isModal()
Indicates whether the dialog is modal.This method is obsolete and is kept for backwards compatiblity only. Use
getModalityType()
instead.- Returns:
true
if this dialog window is modal;false
otherwise- See Also:
DEFAULT_MODALITY_TYPE
,Dialog.ModalityType.MODELESS
,setModal(boolean)
,getModalityType()
,setModalityType(java.awt.Dialog.ModalityType)
-
setModal
public void setModal(boolean modal)
Specifies whether this dialog should be 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.
- Parameters:
modal
- specifies whether dialog blocks input to other windows when shown; calling tosetModal(true)
is equivalent tosetModalityType(Dialog.DEFAULT_MODALITY_TYPE)
, and calling tosetModal(false)
is equvivalent tosetModalityType(Dialog.ModalityType.MODELESS)
- Since:
- 1.1
- See Also:
DEFAULT_MODALITY_TYPE
,Dialog.ModalityType.MODELESS
,isModal()
,getModalityType()
,setModalityType(java.awt.Dialog.ModalityType)
-
getModalityType
public Dialog.ModalityType getModalityType()
Returns the modality type of this dialog.- Returns:
- modality type of this dialog
- Since:
- 1.6
- See Also:
setModalityType(java.awt.Dialog.ModalityType)
-
setModalityType
public void setModalityType(Dialog.ModalityType type)
Sets the modality type for this dialog. SeeModalityType
for possible modality types.If the given modality type is not supported,
MODELESS
is used. You may want to callgetModalityType()
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.
- Parameters:
type
- specifies whether dialog blocks input to other windows when shown.null
value and unsupported modality types are equivalent toMODELESS
- Throws:
SecurityException
- if the calling thread does not have permission to create modal dialogs with the givenmodalityType
- Since:
- 1.6
- See Also:
getModalityType()
,Toolkit.isModalityTypeSupported(java.awt.Dialog.ModalityType)
-
getTitle
public String getTitle()
Gets the title of the dialog. The title is displayed in the dialog's border.- Returns:
- the title of this dialog window. The title may be
null
. - See Also:
setTitle(java.lang.String)
-
setTitle
public void setTitle(String title)
Sets the title of the Dialog.- Parameters:
title
- the title displayed in the dialog's border; a null value results in an empty title- See Also:
getTitle()
-
setVisible
public void setVisible(boolean b)
Shows or hides thisDialog
depending on the value of parameterb
.- Overrides:
setVisible
in classWindow
- Parameters:
b
- iftrue
, makes theDialog
visible, otherwise hides theDialog
. 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. Iffalse
, hides theDialog
and then causessetVisible(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 callingsetVisible(false)
ordispose
.setVisible(false)
: Hides the dialog and then returns onsetVisible(true)
if it is currently blocked.- It is OK to call this method from the event dispatching thread because the toolkit ensures that other events are not blocked while this method is blocked.
- See Also:
Window.setVisible(boolean)
,Window.dispose()
,Component.isDisplayable()
,Component.validate()
,isModal()
-
show
@Deprecated public void show()
Deprecated. As of JDK version 1.5, replaced bysetVisible(boolean)
.Makes theDialog
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.
- Overrides:
show
in classWindow
- See Also:
Component.hide()
,Component.isDisplayable()
,Component.validate()
,isModal()
,Window.setVisible(boolean)
-
hide
@Deprecated public void hide()
Deprecated. As of JDK version 1.5, replaced bysetVisible(boolean)
.Hides the Dialog and then causesshow
to return if it is currently blocked.- Overrides:
hide
in classWindow
- See Also:
Window.show()
,Window.dispose()
,Window.setVisible(boolean)
-
toBack
public 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.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.
- Overrides:
toBack
in classWindow
- See Also:
Window.toBack()
-
isResizable
public boolean isResizable()
Indicates whether this dialog is resizable by the user. By default, all dialogs are initially resizable.- Returns:
true
if the user can resize the dialog;false
otherwise.- See Also:
setResizable(boolean)
-
setResizable
public void setResizable(boolean resizable)
Sets whether this dialog is resizable by the user.- Parameters:
resizable
-true
if the user can resize this dialog;false
otherwise.- See Also:
isResizable()
-
setUndecorated
public void setUndecorated(boolean undecorated)
Disables or enables decorations for this dialog.This method can only be called while the dialog is not displayable. To make this dialog decorated, it must be opaque and have the default shape, otherwise the
IllegalComponentStateException
will be thrown. Refer toWindow.setShape(java.awt.Shape)
,Window.setOpacity(float)
andWindow.setBackground(java.awt.Color)
for details- Parameters:
undecorated
-true
if no dialog decorations are to be enabled;false
if dialog decorations are to be enabled- Throws:
IllegalComponentStateException
- if the dialog is displayableIllegalComponentStateException
- ifundecorated
isfalse
, and this dialog does not have the default shapeIllegalComponentStateException
- ifundecorated
isfalse
, and this dialog opacity is less than1.0f
IllegalComponentStateException
- ifundecorated
isfalse
, and the alpha value of this dialog background color is less than1.0f
- Since:
- 1.4
- See Also:
isUndecorated()
,Component.isDisplayable()
,Window.getShape()
,Window.getOpacity()
,Window.getBackground()
-
isUndecorated
public boolean isUndecorated()
Indicates whether this dialog is undecorated. By default, all dialogs are initially decorated.- Returns:
true
if dialog is undecorated;false
otherwise.- Since:
- 1.4
- See Also:
setUndecorated(boolean)
-
setOpacity
public void setOpacity(float opacity)
Sets the opacity of the window.The opacity value is in the range [0..1]. Note that setting the opacity level of 0 may or may not disable the mouse event handling on this window. This is a platform-dependent behavior.
The following conditions must be met in order to set the opacity value less than
1.0f
:- The
TRANSLUCENT
translucency must be supported by the underlying system - The window must be undecorated (see
Frame.setUndecorated(boolean)
andsetUndecorated(boolean)
) - The window must not be in full-screen mode (see
GraphicsDevice.setFullScreenWindow(Window)
)
If the requested opacity value is less than
1.0f
, and any of the above conditions are not met, the window opacity will not change, and theIllegalComponentStateException
will be thrown.The translucency levels of individual pixels may also be effected by the alpha component of their color (see
Window.setBackground(Color)
) and the current shape of this window (seeWindow.setShape(Shape)
).- Overrides:
setOpacity
in classWindow
- Parameters:
opacity
- the opacity level to set to the window- See Also:
Window.getOpacity()
,Window.setBackground(Color)
,Window.setShape(Shape)
,Frame.isUndecorated()
,isUndecorated()
,GraphicsDevice.WindowTranslucency
,GraphicsDevice.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
- The
-
setShape
public void setShape(Shape shape)
Sets the shape of the window.Setting a shape cuts off some parts of the window. Only the parts that belong to the given
Shape
remain visible and clickable. If the shape argument isnull
, this method restores the default shape, making the window rectangular on most platforms.The following conditions must be met to set a non-null shape:
- The
PERPIXEL_TRANSPARENT
translucency must be supported by the underlying system - The window must be undecorated (see
Frame.setUndecorated(boolean)
andsetUndecorated(boolean)
) - The window must not be in full-screen mode (see
GraphicsDevice.setFullScreenWindow(Window)
)
If the requested shape is not
null
, and any of the above conditions are not met, the shape of this window will not change, and either theUnsupportedOperationException
orIllegalComponentStateException
will be thrown.The tranlucency levels of individual pixels may also be effected by the alpha component of their color (see
Window.setBackground(Color)
) and the opacity value (seeWindow.setOpacity(float)
). SeeGraphicsDevice.WindowTranslucency
for more details.- Overrides:
setShape
in classWindow
- Parameters:
shape
- the shape to set to the window- See Also:
Window.getShape()
,Window.setBackground(Color)
,Window.setOpacity(float)
,Frame.isUndecorated()
,isUndecorated()
,GraphicsDevice.WindowTranslucency
,GraphicsDevice.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
- The
-
setBackground
public void setBackground(Color bgColor)
Sets the background color of this window.If the windowing system supports the
PERPIXEL_TRANSLUCENT
tranclucency, the alpha component of the given background color may effect the mode of operation for this window: it indicates whether this window must be opaque (alpha equals1.0f
) or per-pixel translucent (alpha is less than1.0f
). If the given background color isnull
, the window is considered completely opaque.All the following conditions must be met to enable the per-pixel transparency mode for this window:
- The
PERPIXEL_TRANSLUCENT
translucency must be supported by the graphics device where this window is located - The window must be undecorated (see
Frame.setUndecorated(boolean)
andsetUndecorated(boolean)
) - The window must not be in full-screen mode (see
GraphicsDevice.setFullScreenWindow(Window)
)
If the alpha component of the requested background color is less than
1.0f
, and any of the above conditions are not met, the background color of this window will not change, the alpha component of the given background color will not affect the mode of operation for this window, and either theUnsupportedOperationException
orIllegalComponentStateException
will be thrown.When the window is per-pixel translucent, the drawing sub-system respects the alpha value of each individual pixel. If a pixel gets painted with the alpha color component equal to zero, it becomes visually transparent. If the alpha of the pixel is equal to 1.0f, the pixel is fully opaque. Interim values of the alpha color component make the pixel semi-transparent. In this mode, the background of the window gets painted with the alpha value of the given background color. If the alpha value of the argument of this method is equal to
0
, the background is not painted at all.The actual level of translucency of a given pixel also depends on window opacity (see
Window.setOpacity(float)
), as well as the current shape of this window (seeWindow.setShape(Shape)
).Note that painting a pixel with the alpha value of
0
may or may not disable the mouse event handling on this pixel. This is a platform-dependent behavior. To make sure the mouse events do not get dispatched to a particular pixel, the pixel must be excluded from the shape of the window.Enabling the per-pixel translucency mode may change the graphics configuration of this window due to the native platform requirements.
- Overrides:
setBackground
in classWindow
- Parameters:
bgColor
- the color to become this window's background color.- See Also:
Window.getBackground()
,Window.isOpaque()
,Window.setOpacity(float)
,Window.setShape(Shape)
,Frame.isUndecorated()
,isUndecorated()
,GraphicsDevice.WindowTranslucency
,GraphicsDevice.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
,GraphicsConfiguration.isTranslucencyCapable()
- The
-
paramString
protected String paramString()
Returns a string representing the state of this dialog. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not benull
.- Overrides:
paramString
in classContainer
- Returns:
- the parameter string of this dialog window.
-
getAccessibleContext
public AccessibleContext getAccessibleContext()
Gets the AccessibleContext associated with this Dialog. For dialogs, the AccessibleContext takes the form of an AccessibleAWTDialog. A new AccessibleAWTDialog instance is created if necessary.- Specified by:
getAccessibleContext
in interfaceAccessible
- Overrides:
getAccessibleContext
in classWindow
- Returns:
- an AccessibleAWTDialog that serves as the AccessibleContext of this Dialog
- Since:
- 1.3
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
21/11/2024 21:44:51 Cette version de la page est en cache (à la date du 21/11/2024 21:44:51) afin d'accélérer le traitement. Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la dernère version de la page.Document créé le 16/09/2006, dernière modification le 04/03/2020
Source du document imprimé : https://www.gaudry.be/java-api-rf-java/awt/dialog.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.