javax.swing

Class JDialog

Implemented Interfaces:
Accessible, ImageObserver, MenuContainer, RootPaneContainer, Serializable, WindowConstants

public class JDialog
extends Dialog
implements Accessible, WindowConstants, RootPaneContainer

A dialog window. This is an extension of Dialog that provides support for the Swing architecture. Most importantly it contains a JRootPane as it's only top-level child, that manages the content pane, the menu and a glass pane. Also, unlike java.awt.Dialogs, JDialogs support the Swing Pluggable Look & Feel architecture.
See Also:
Serialized Form

Nested Class Summary

protected class
JDialog.AccessibleJDialog
Provides accessibility support for JDialogs.

Nested classes/interfaces inherited from class java.awt.Dialog

Dialog.AccessibleAWTDialog

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.BltBufferStrategy, Component.FlipBufferStrategy

Field Summary

protected AccessibleContext
accessibleContext
DOCUMENT ME!
protected JRootPane
rootPane
The single RootPane in the Dialog.
protected boolean
rootPaneCheckingEnabled
Whether checking is enabled on the RootPane.

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

Fields inherited from interface javax.swing.WindowConstants

DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE

Constructor Summary

JDialog()
Default constructor for subclasses.
JDialog(Dialog owner)
Creates a new non-modal JDialog with no title using the given owner.
JDialog(Dialog owner, boolean modal)
Creates a new JDialog with no title using the given modal setting and owner.
JDialog(Dialog owner, String title)
Creates a new non-modal JDialog using the given title and owner.
JDialog(Dialog owner, String title, boolean modal)
Creates a new JDialog using the given modal settings, title, and owner.
JDialog(Dialog owner, String title, boolean modal, GraphicsConfiguration gc)
Creates a new JDialog using the given modal settings, title, owner and graphics configuration.
JDialog(Frame owner)
Creates a new non-modal JDialog with no title using the given owner.
JDialog(Frame owner, boolean modal)
Creates a new JDialog with no title using the given modal setting and owner.
JDialog(Frame owner, String title)
Creates a new non-modal JDialog using the given title and owner.
JDialog(Frame owner, String title, boolean modal)
Creates a new JDialog using the given modal settings, title, and owner.
JDialog(Frame owner, String title, boolean modal, GraphicsConfiguration gc)
Creates a new JDialog using the given modal settings, title, owner and graphics configuration.

Method Summary

protected void
addImpl(Component comp, Object constraints, int index)
This method is called when a component is added to the the JDialog.
protected JRootPane
createRootPane()
This method creates a new JRootPane.
protected void
dialogInit()
This method is called to initialize the JDialog.
AccessibleContext
getAccessibleContext()
DOCUMENT ME!
Container
getContentPane()
This method returns the ContentPane in the JRootPane.
int
getDefaultCloseOperation()
This method returns the action taken when the JDialog is closed.
Component
getGlassPane()
This method returns the GlassPane for this JDialog.
JMenuBar
getJMenuBar()
This method returns the JMenuBar used in this JDialog.
JLayeredPane
getLayeredPane()
This method returns the JLayeredPane used with this JDialog.
Dimension
getPreferredSize()
This method returns the preferred size of the JDialog.
JRootPane
getRootPane()
This method returns the JRootPane used with this JDialog.
static boolean
isDefaultLookAndFeelDecorated()
This method returns whether JDialogs will have their window decorations provided by the Look and Feel.
protected boolean
isRootPaneCheckingEnabled()
This method returns whether rootPane checking is enabled.
protected String
paramString()
This method returns a String describing the JDialog.
protected void
processWindowEvent(WindowEvent e)
This method handles window events.
void
remove(Component comp)
This method removes a component from the JDialog.
void
setContentPane(Container contentPane)
This method sets the ContentPane to use with this JDialog.
void
setDefaultCloseOperation(int operation)
This method sets the action to take when the JDialog is closed.
static void
setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated)
This method sets whether JDialogs will have their window decorations provided by the Look and Feel.
void
setGlassPane(Component glassPane)
This method sets the GlassPane for this JDialog.
void
setJMenuBar(JMenuBar menubar)
This method sets the JMenuBar used in this JDialog.
void
setLayeredPane(JLayeredPane layeredPane)
This method sets the JLayeredPane used in the JDialog.
void
setLayout(LayoutManager manager)
This method sets the LayoutManager used in the JDialog.
protected void
setRootPane(JRootPane root)
This method sets the JRootPane used with this JDialog.
protected void
setRootPaneCheckingEnabled(boolean enabled)
This method sets whether rootPane checking is enabled.
void
update(Graphics g)
This method simply calls paint and returns.

Methods inherited from class java.awt.Dialog

addNotify, dispose, getAccessibleContext, getTitle, hide, isModal, isResizable, isUndecorated, paramString, setModal, setResizable, setTitle, setUndecorated, show

Methods inherited from class java.awt.Window

addNotify, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, extends EventListener> T[] getListeners, getAccessibleContext, getBufferStrategy, getFocusCycleRootAncestor, getFocusOwner, getFocusableWindowState, getGraphicsConfiguration, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isAlwaysOnTop, isFocusCycleRoot, isFocusableWindow, isFocused, isShowing, pack, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setCursor, setFocusCycleRoot, setFocusableWindowState, setLocationRelativeTo, toBack, toFront, void hide, void show

Methods inherited from class java.awt.Container

add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, extends EventListener> T[] getListeners, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponentZOrder, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, 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, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

accessibleContext

protected AccessibleContext accessibleContext
DOCUMENT ME!

rootPane

protected JRootPane rootPane
The single RootPane in the Dialog.

rootPaneCheckingEnabled

protected boolean rootPaneCheckingEnabled
Whether checking is enabled on the RootPane.

Constructor Details

JDialog

public JDialog()
Default constructor for subclasses.

JDialog

public JDialog(Dialog owner)
Creates a new non-modal JDialog with no title using the given owner.
Parameters:
owner - The owner of the JDialog.

JDialog

public JDialog(Dialog owner,
               boolean modal)
Creates a new JDialog with no title using the given modal setting and owner.
Parameters:
owner - The owner of the JDialog.
modal - Whether the JDialog is modal.

JDialog

public JDialog(Dialog owner,
               String title)
Creates a new non-modal JDialog using the given title and owner.
Parameters:
owner - The owner of the JDialog.
title - The title of the JDialog.

JDialog

public JDialog(Dialog owner,
               String title,
               boolean modal)
Creates a new JDialog using the given modal settings, title, and owner.
Parameters:
owner - The owner of the JDialog.
title - The title of the JDialog.
modal - Whether the JDialog is modal.

JDialog

public JDialog(Dialog owner,
               String title,
               boolean modal,
               GraphicsConfiguration gc)
Creates a new JDialog using the given modal settings, title, owner and graphics configuration.
Parameters:
owner - The owner of the JDialog.
title - The title of the JDialog.
modal - Whether the JDialog is modal.
gc - The Graphics Configuration to use.

JDialog

public JDialog(Frame owner)
Creates a new non-modal JDialog with no title using the given owner.
Parameters:
owner - The owner of the JDialog.

JDialog

public JDialog(Frame owner,
               boolean modal)
Creates a new JDialog with no title using the given modal setting and owner.
Parameters:
owner - The owner of the JDialog.
modal - Whether the JDialog is modal.

JDialog

public JDialog(Frame owner,
               String title)
Creates a new non-modal JDialog using the given title and owner.
Parameters:
owner - The owner of the JDialog.
title - The title of the JDialog.

JDialog

public JDialog(Frame owner,
               String title,
               boolean modal)
Creates a new JDialog using the given modal settings, title, and owner.
Parameters:
owner - The owner of the JDialog.
title - The title of the JDialog.
modal - Whether the JDialog is modal.

JDialog

public JDialog(Frame owner,
               String title,
               boolean modal,
               GraphicsConfiguration gc)
Creates a new JDialog using the given modal settings, title, owner and graphics configuration.
Parameters:
owner - The owner of the JDialog.
title - The title of the JDialog.
modal - Whether the JDialog is modal.
gc - The Graphics Configuration to use.

Method Details

addImpl

protected void addImpl(Component comp,
                       Object constraints,
                       int index)
This method is called when a component is added to the the JDialog. Calling this method with rootPaneCheckingEnabled will cause an Error to be thrown.
Overrides:
addImpl in interface Container
Parameters:
comp - The component to add.
constraints - The constraints.
index - The position of the component.

createRootPane

protected JRootPane createRootPane()
This method creates a new JRootPane.
Returns:
A new JRootPane.

dialogInit

protected void dialogInit()
This method is called to initialize the JDialog. It sets the layout used, the locale, and creates the RootPane.

getAccessibleContext

public AccessibleContext getAccessibleContext()
DOCUMENT ME!
Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in interface Dialog
Returns:
DOCUMENT ME!

getContentPane

public Container getContentPane()
This method returns the ContentPane in the JRootPane.
Specified by:
getContentPane in interface RootPaneContainer
Returns:
The ContentPane in the JRootPane.

getDefaultCloseOperation

public int getDefaultCloseOperation()
This method returns the action taken when the JDialog is closed.
Returns:
The action to take.

getGlassPane

public Component getGlassPane()
This method returns the GlassPane for this JDialog.
Specified by:
getGlassPane in interface RootPaneContainer
Returns:
The GlassPane for this JDialog.

getJMenuBar

public JMenuBar getJMenuBar()
This method returns the JMenuBar used in this JDialog.
Returns:
The JMenuBar in the JDialog.

getLayeredPane

public JLayeredPane getLayeredPane()
This method returns the JLayeredPane used with this JDialog.
Specified by:
getLayeredPane in interface RootPaneContainer
Returns:
The JLayeredPane used with this JDialog.

getPreferredSize

public Dimension getPreferredSize()
This method returns the preferred size of the JDialog.
Overrides:
getPreferredSize in interface Container
Returns:
The preferred size.

getRootPane

public JRootPane getRootPane()
This method returns the JRootPane used with this JDialog.
Specified by:
getRootPane in interface RootPaneContainer
Returns:
The JRootPane used with this JDialog.

isDefaultLookAndFeelDecorated

public static boolean isDefaultLookAndFeelDecorated()
This method returns whether JDialogs will have their window decorations provided by the Look and Feel.
Returns:
Whether the window decorations are Look and Feel provided.

isRootPaneCheckingEnabled

protected boolean isRootPaneCheckingEnabled()
This method returns whether rootPane checking is enabled.
Returns:
Whether rootPane checking is enabled.

paramString

protected String paramString()
This method returns a String describing the JDialog.
Overrides:
paramString in interface Dialog
Returns:
A String describing the JDialog.

processWindowEvent

protected void processWindowEvent(WindowEvent e)
This method handles window events. This allows the JDialog to honour its default close operation.
Overrides:
processWindowEvent in interface Window
Parameters:
e - The WindowEvent.

remove

public void remove(Component comp)
This method removes a component from the JDialog.
Overrides:
remove in interface Container
Parameters:
comp - The component to remove.

setContentPane

public void setContentPane(Container contentPane)
This method sets the ContentPane to use with this JDialog. If the ContentPane given is null, this method will throw an exception.
Specified by:
setContentPane in interface RootPaneContainer
Parameters:
contentPane - The ContentPane to use with the JDialog.

setDefaultCloseOperation

public void setDefaultCloseOperation(int operation)
This method sets the action to take when the JDialog is closed.
Parameters:
operation - The action to take.

setDefaultLookAndFeelDecorated

public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated)
This method sets whether JDialogs will have their window decorations provided by the Look and Feel.
Parameters:
defaultLookAndFeelDecorated - Whether the window decorations are Look and Feel provided.

setGlassPane

public void setGlassPane(Component glassPane)
This method sets the GlassPane for this JDialog.
Specified by:
setGlassPane in interface RootPaneContainer
Parameters:
glassPane - The GlassPane for this JDialog.

setJMenuBar

public void setJMenuBar(JMenuBar menubar)
This method sets the JMenuBar used in this JDialog.
Parameters:
menubar - The JMenuBar to use.

setLayeredPane

public void setLayeredPane(JLayeredPane layeredPane)
This method sets the JLayeredPane used in the JDialog. If the given JLayeredPane is null, then this method will throw an Error.
Specified by:
setLayeredPane in interface RootPaneContainer
Parameters:
layeredPane - The JLayeredPane to use.

setLayout

public void setLayout(LayoutManager manager)
This method sets the LayoutManager used in the JDialog. This method will throw an Error if rootPaneChecking is enabled.
Overrides:
setLayout in interface Container
Parameters:
manager - The LayoutManager to use.

setRootPane

protected void setRootPane(JRootPane root)
This method sets the JRootPane used with this JDialog.
Parameters:
root - The JRootPane to use.

setRootPaneCheckingEnabled

protected void setRootPaneCheckingEnabled(boolean enabled)
This method sets whether rootPane checking is enabled.
Parameters:
enabled - Whether rootPane checking is enabled.

update

public void update(Graphics g)
This method simply calls paint and returns.
Overrides:
update in interface Container
Parameters:
g - The Graphics object to paint with.

JDialog.java -- Copyright (C) 2002, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.