JSR-62 (Final)

java.awt
Class Dialog

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Dialog
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
FileDialog

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 must have either a frame or another dialog defined as its owner when it's constructed. When the owner window of a visible dialog is hidden or minimized, the dialog will automatically be hidden from the user. When the owner window is subsequently re-opened, then the dialog is made visible to the user again.

A dialog can be either modeless (the default) or modal. A modal dialog is one which blocks input to all other toplevel windows in the app context, except for any windows created with the dialog as their owner.

Dialogs are capable of generating the following window events: WindowOpened, WindowClosing, WindowClosed, WindowActivated, WindowDeactivated.

Restrictions

Implementations of Dialog in Personal Profile exhibit certain restrictions, specifically:

Since:
JDK1.0
See Also:
WindowEvent, Window.addWindowListener(java.awt.event.WindowListener), Serialized Form

Field Summary
 
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(Frame owner)
          Constructs an initially invisible, non-modal Dialog with an empty title and the specified owner frame.
Dialog(Frame owner, boolean modal)
          Constructs an initially invisible Dialog with an empty title, the specified owner frame and modality.
Dialog(Frame owner, String title)
          Constructs an initially invisible, non-modal Dialog with the specified owner frame and title.
Dialog(Frame owner, String title, boolean modal)
          Constructs an initially invisible Dialog with the specified owner frame, title, and modality.
 
Method Summary
 void dispose()
          Disposes the Dialog and then causes show() to return if it is currently blocked.
 String getTitle()
          Gets the title of the dialog.
 void hide()
          Hides the Dialog and then causes show() to return if it is currently blocked.
 boolean isModal()
          Indicates whether the dialog is modal.
 boolean isResizable()
          Indicates whether this dialog is resizable by the user.
protected  String paramString()
          Returns the parameter string representing the state of this dialog window.
 void setModal(boolean b)
          Specifies whether this dialog should be modal.
 void setResizable(boolean resizable)
          Sets whether this dialog is resizable by the user.
 void setTitle(String title)
          Sets the title of the Dialog.
 void show()
          Makes the Dialog visible.
 
Methods inherited from class java.awt.Window
addWindowListener, getFocusOwner, getGraphicsConfiguration, getLocale, getToolkit, getWarningString, isShowing, pack, postEvent, processEvent, processWindowEvent, removeWindowListener, setCursor, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, getBackground, getBounds, getBounds, getColorModel, getCursor, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getLocation, getLocation, getLocationOnScreen, getName, getParent, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Dialog

public Dialog(Frame owner)
Constructs an initially invisible, non-modal Dialog with an empty title and the specified owner frame.

Parameters:
owner - the owner of the dialog
Throws:
IllegalArgumentException - if owner is null
See Also:
Component.setSize(int, int), Component.setVisible(boolean)

Dialog

public Dialog(Frame owner,
              boolean modal)
Constructs an initially invisible Dialog with an empty title, the specified owner frame and modality.

Parameters:
owner - the owner of the dialog
modal - if true, dialog blocks input to other app windows when shown
Throws:
IllegalArgumentException - if owner is null

Dialog

public Dialog(Frame owner,
              String title)
Constructs an initially invisible, non-modal Dialog with the specified owner frame and title.

Note: This operation is subject to restriction in Personal Profile.

Parameters:
owner - the owner of the dialog
title - the title of the dialog. A null value will be accepted without causing a NullPointerException to be thrown.
Throws:
IllegalArgumentException - if owner is null
See Also:
Component.setSize(int, int), Component.setVisible(boolean)

Dialog

public Dialog(Frame owner,
              String title,
              boolean modal)
Constructs an initially invisible Dialog with the specified owner frame, title, and modality.

Note: This operation is subject to restriction in Personal Profile.

Parameters:
owner - the owner of the dialog
title - the title of the dialog. A null value will be accepted without causing a NullPointerException to be thrown.
modal - if true, dialog blocks input to other app windows when shown
Throws:
IllegalArgumentException - if owner is null
See Also:
Component.setSize(int, int), Component.setVisible(boolean)
Method Detail

isModal

public boolean isModal()
Indicates whether the dialog is modal. When a modal Dialog is made visible, user input will be blocked to the other windows in the app context, except for any windows created with this dialog as their owner.

Returns:
true if this dialog window is modal; false otherwise.
See Also:
setModal(boolean)

setModal

public void setModal(boolean b)
Specifies whether this dialog should be modal.

Since:
JDK1.1
See Also:
isModal()

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.

Note: This operation is subject to restriction in Personal Profile.

Parameters:
title - the title displayed in the dialog's border
See Also:
getTitle()

show

public void show()
Makes the 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.

Overrides:
show in class Window
See Also:
Component.hide(), Component.isDisplayable(), Component.validate(), isModal()

hide

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

Overrides:
hide in class Window
See Also:
Window.show(), Window.dispose()

dispose

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

Overrides:
dispose in class Window
See Also:
Component.isDisplayable(), Window.pack(), Window.show()

isResizable

public boolean isResizable()
Indicates whether this dialog is resizable by the user.

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.

Note: This operation is subject to restriction in Personal Profile.

Parameters:
resizable - true if the user can resize this dialog; false otherwise.
See Also:
isResizable()

paramString

protected String paramString()
Returns the parameter string representing the state of this dialog window. This string is useful for debugging.

Overrides:
paramString in class Container
Returns:
the parameter string of this dialog window.

JSR-62 (Final)

Java and Java 2D are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
Copyright 1993 - 2002 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, California 94303, U.S.A. All Rights Reserved.
Use of this specification is subject to this license.