0N/A/*
2722N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/Apackage javax.swing;
0N/A
0N/Aimport java.awt.*;
0N/Aimport java.awt.event.*;
0N/Aimport javax.accessibility.*;
0N/A
0N/A/**
0N/A * The main class for creating a dialog window. You can use this class
0N/A * to create a custom dialog, or invoke the many class methods
0N/A * in {@link JOptionPane} to create a variety of standard dialogs.
0N/A * For information about creating dialogs, see
0N/A * <em>The Java Tutorial</em> section
0N/A * <a
0N/A href="http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html">How
0N/A * to Make Dialogs</a>.
0N/A *
0N/A * <p>
0N/A *
2722N/A * The {@code JDialog} component contains a {@code JRootPane}
0N/A * as its only child.
2722N/A * The {@code contentPane} should be the parent of any children of the
2722N/A * {@code JDialog}.
2722N/A * As a convenience {@code add} and its variants, {@code remove} and
2722N/A * {@code setLayout} have been overridden to forward to the
2722N/A * {@code contentPane} as necessary. This means you can write:
0N/A * <pre>
0N/A * dialog.add(child);
0N/A * </pre>
0N/A * And the child will be added to the contentPane.
2722N/A * The {@code contentPane} is always non-{@code null}.
2722N/A * Attempting to set it to {@code null} generates an exception.
2722N/A * The default {@code contentPane} has a {@code BorderLayout}
0N/A * manager set on it.
0N/A * Refer to {@link javax.swing.RootPaneContainer}
2722N/A * for details on adding, removing and setting the {@code LayoutManager}
2722N/A * of a {@code JDialog}.
0N/A * <p>
2722N/A * Please see the {@code JRootPane} documentation for a complete
2722N/A * description of the {@code contentPane}, {@code glassPane},
2722N/A * and {@code layeredPane} components.
0N/A * <p>
2722N/A * In a multi-screen environment, you can create a {@code JDialog}
0N/A * on a different screen device than its owner. See {@link java.awt.Frame} for
0N/A * more information.
0N/A * <p>
0N/A * <strong>Warning:</strong> Swing is not thread safe. For more
0N/A * information see <a
0N/A * href="package-summary.html#threading">Swing's Threading
0N/A * Policy</a>.
0N/A * <p>
0N/A * <strong>Warning:</strong>
0N/A * Serialized objects of this class will not be compatible with
0N/A * future Swing releases. The current serialization support is
0N/A * appropriate for short term storage or RMI between applications running
0N/A * the same version of Swing. As of 1.4, support for long term storage
0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup>
2722N/A * has been added to the {@code java.beans} package.
0N/A * Please see {@link java.beans.XMLEncoder}.
0N/A *
0N/A * @see JOptionPane
0N/A * @see JRootPane
0N/A * @see javax.swing.RootPaneContainer
0N/A *
0N/A * @beaninfo
0N/A * attribute: isContainer true
0N/A * attribute: containerDelegate getContentPane
0N/A * description: A toplevel window for creating dialog boxes.
0N/A *
0N/A * @author David Kloba
0N/A * @author James Gosling
0N/A * @author Scott Violet
0N/A */
0N/Apublic class JDialog extends Dialog implements WindowConstants,
0N/A Accessible,
0N/A RootPaneContainer,
0N/A TransferHandler.HasGetTransferHandler
0N/A{
0N/A /**
0N/A * Key into the AppContext, used to check if should provide decorations
0N/A * by default.
0N/A */
0N/A private static final Object defaultLookAndFeelDecoratedKey =
0N/A new StringBuffer("JDialog.defaultLookAndFeelDecorated");
0N/A
0N/A private int defaultCloseOperation = HIDE_ON_CLOSE;
0N/A
0N/A /**
0N/A * @see #getRootPane
0N/A * @see #setRootPane
0N/A */
0N/A protected JRootPane rootPane;
0N/A
0N/A /**
2722N/A * If true then calls to {@code add} and {@code setLayout}
2722N/A * will be forwarded to the {@code contentPane}. This is initially
2722N/A * false, but is set to true when the {@code JDialog} is constructed.
0N/A *
0N/A * @see #isRootPaneCheckingEnabled
0N/A * @see #setRootPaneCheckingEnabled
0N/A * @see javax.swing.RootPaneContainer
0N/A */
0N/A protected boolean rootPaneCheckingEnabled = false;
0N/A
0N/A /**
2722N/A * The {@code TransferHandler} for this dialog.
0N/A */
0N/A private TransferHandler transferHandler;
0N/A
0N/A /**
0N/A * Creates a modeless dialog without a title and without a specified
2722N/A * {@code Frame} owner. A shared, hidden frame will be
0N/A * set as the owner of the dialog.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
0N/A * <p>
0N/A * NOTE: This constructor does not allow you to create an unowned
2722N/A * {@code JDialog}. To create an unowned {@code JDialog}
2722N/A * you must use either the {@code JDialog(Window)} or
2722N/A * {@code JDialog(Dialog)} constructor with an argument of
2722N/A * {@code null}.
0N/A *
2722N/A * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
2722N/A * returns {@code true}.
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A */
0N/A public JDialog() {
0N/A this((Frame)null, false);
0N/A }
0N/A
0N/A /**
3185N/A * Creates a modeless dialog with the specified {@code Frame}
3185N/A * as its owner and an empty title. If {@code owner}
2722N/A * is {@code null}, a shared, hidden frame will be set as the
0N/A * owner of the dialog.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
0N/A * <p>
0N/A * NOTE: This constructor does not allow you to create an unowned
2722N/A * {@code JDialog}. To create an unowned {@code JDialog}
2722N/A * you must use either the {@code JDialog(Window)} or
2722N/A * {@code JDialog(Dialog)} constructor with an argument of
2722N/A * {@code null}.
0N/A *
2722N/A * @param owner the {@code Frame} from which the dialog is displayed
2722N/A * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
2722N/A * returns {@code true}.
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A */
0N/A public JDialog(Frame owner) {
0N/A this(owner, false);
0N/A }
0N/A
0N/A /**
3185N/A * Creates a dialog with an empty title and the specified modality and
3185N/A * {@code Frame} as its owner. If {@code owner} is {@code null},
0N/A * a shared, hidden frame will be set as the owner of the dialog.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
0N/A * <p>
0N/A * NOTE: This constructor does not allow you to create an unowned
2722N/A * {@code JDialog}. To create an unowned {@code JDialog}
2722N/A * you must use either the {@code JDialog(Window)} or
2722N/A * {@code JDialog(Dialog)} constructor with an argument of
2722N/A * {@code null}.
0N/A *
2722N/A * @param owner the {@code Frame} from which the dialog is displayed
0N/A * @param modal specifies whether dialog blocks user input to other top-level
2722N/A * windows when shown. If {@code true}, the modality type property is set to
2722N/A * {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless.
2722N/A * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
2722N/A * returns {@code true}.
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A */
0N/A public JDialog(Frame owner, boolean modal) {
3185N/A this(owner, "", modal);
0N/A }
0N/A
0N/A /**
0N/A * Creates a modeless dialog with the specified title and
2722N/A * with the specified owner frame. If {@code owner}
2722N/A * is {@code null}, a shared, hidden frame will be set as the
0N/A * owner of the dialog.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
0N/A * <p>
0N/A * NOTE: This constructor does not allow you to create an unowned
2722N/A * {@code JDialog}. To create an unowned {@code JDialog}
2722N/A * you must use either the {@code JDialog(Window)} or
2722N/A * {@code JDialog(Dialog)} constructor with an argument of
2722N/A * {@code null}.
0N/A *
2722N/A * @param owner the {@code Frame} from which the dialog is displayed
2722N/A * @param title the {@code String} to display in the dialog's
0N/A * title bar
2722N/A * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
2722N/A * returns {@code true}.
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A */
0N/A public JDialog(Frame owner, String title) {
0N/A this(owner, title, false);
0N/A }
0N/A
0N/A /**
2722N/A * Creates a dialog with the specified title, owner {@code Frame}
2722N/A * and modality. If {@code owner} is {@code null},
0N/A * a shared, hidden frame will be set as the owner of this dialog.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
0N/A * <p>
2722N/A * NOTE: Any popup components ({@code JComboBox},
2722N/A * {@code JPopupMenu}, {@code JMenuBar})
0N/A * created within a modal dialog will be forced to be lightweight.
0N/A * <p>
0N/A * NOTE: This constructor does not allow you to create an unowned
2722N/A * {@code JDialog}. To create an unowned {@code JDialog}
2722N/A * you must use either the {@code JDialog(Window)} or
2722N/A * {@code JDialog(Dialog)} constructor with an argument of
2722N/A * {@code null}.
0N/A *
2722N/A * @param owner the {@code Frame} from which the dialog is displayed
2722N/A * @param title the {@code String} to display in the dialog's
0N/A * title bar
0N/A * @param modal specifies whether dialog blocks user input to other top-level
2722N/A * windows when shown. If {@code true}, the modality type property is set to
2722N/A * {@code DEFAULT_MODALITY_TYPE} otherwise the dialog is modeless
2722N/A * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
2722N/A * returns {@code true}.
0N/A *
0N/A * @see java.awt.Dialog.ModalityType
0N/A * @see java.awt.Dialog.ModalityType#MODELESS
0N/A * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
0N/A * @see java.awt.Dialog#setModal
0N/A * @see java.awt.Dialog#setModalityType
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A */
0N/A public JDialog(Frame owner, String title, boolean modal) {
0N/A super(owner == null? SwingUtilities.getSharedOwnerFrame() : owner,
0N/A title, modal);
0N/A if (owner == null) {
0N/A WindowListener ownerShutdownListener =
625N/A SwingUtilities.getSharedOwnerFrameShutdownListener();
0N/A addWindowListener(ownerShutdownListener);
0N/A }
0N/A dialogInit();
0N/A }
0N/A
0N/A /**
0N/A * Creates a dialog with the specified title,
2722N/A * owner {@code Frame}, modality and {@code GraphicsConfiguration}.
2722N/A * If {@code owner} is {@code null},
0N/A * a shared, hidden frame will be set as the owner of this dialog.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
0N/A * <p>
2722N/A * NOTE: Any popup components ({@code JComboBox},
2722N/A * {@code JPopupMenu}, {@code JMenuBar})
0N/A * created within a modal dialog will be forced to be lightweight.
0N/A * <p>
0N/A * NOTE: This constructor does not allow you to create an unowned
2722N/A * {@code JDialog}. To create an unowned {@code JDialog}
2722N/A * you must use either the {@code JDialog(Window)} or
2722N/A * {@code JDialog(Dialog)} constructor with an argument of
2722N/A * {@code null}.
0N/A *
2722N/A * @param owner the {@code Frame} from which the dialog is displayed
2722N/A * @param title the {@code String} to display in the dialog's
0N/A * title bar
0N/A * @param modal specifies whether dialog blocks user input to other top-level
2722N/A * windows when shown. If {@code true}, the modality type property is set to
2722N/A * {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless.
2971N/A * @param gc the {@code GraphicsConfiguration} of the target screen device;
2971N/A * if {@code null}, the default system {@code GraphicsConfiguration}
2971N/A * is assumed
2722N/A * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
2722N/A * returns {@code true}.
0N/A * @see java.awt.Dialog.ModalityType
0N/A * @see java.awt.Dialog.ModalityType#MODELESS
0N/A * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
0N/A * @see java.awt.Dialog#setModal
0N/A * @see java.awt.Dialog#setModalityType
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A * @since 1.4
0N/A */
0N/A public JDialog(Frame owner, String title, boolean modal,
0N/A GraphicsConfiguration gc) {
0N/A super(owner == null? SwingUtilities.getSharedOwnerFrame() : owner,
0N/A title, modal, gc);
0N/A if (owner == null) {
0N/A WindowListener ownerShutdownListener =
625N/A SwingUtilities.getSharedOwnerFrameShutdownListener();
0N/A addWindowListener(ownerShutdownListener);
0N/A }
0N/A dialogInit();
0N/A }
0N/A
0N/A /**
3185N/A * Creates a modeless dialog with the specified {@code Dialog}
3185N/A * as its owner and an empty title.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
0N/A *
2722N/A * @param owner the owner {@code Dialog} from which the dialog is displayed
2722N/A * or {@code null} if this dialog has no owner
2722N/A * @throws HeadlessException {@code if GraphicsEnvironment.isHeadless()}
2722N/A * returns {@code true}.
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A */
0N/A public JDialog(Dialog owner) {
0N/A this(owner, false);
0N/A }
0N/A
0N/A /**
3185N/A * Creates a dialog with an empty title and the specified modality and
3185N/A * {@code Dialog} as its owner.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
0N/A *
2722N/A * @param owner the owner {@code Dialog} from which the dialog is displayed
2722N/A * or {@code null} if this dialog has no owner
0N/A * @param modal specifies whether dialog blocks user input to other top-level
2722N/A * windows when shown. If {@code true}, the modality type property is set to
2722N/A * {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless.
2722N/A * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
2722N/A * returns {@code true}.
0N/A * @see java.awt.Dialog.ModalityType
0N/A * @see java.awt.Dialog.ModalityType#MODELESS
0N/A * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
0N/A * @see java.awt.Dialog#setModal
0N/A * @see java.awt.Dialog#setModalityType
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A */
0N/A public JDialog(Dialog owner, boolean modal) {
3185N/A this(owner, "", modal);
0N/A }
0N/A
0N/A /**
0N/A * Creates a modeless dialog with the specified title and
0N/A * with the specified owner dialog.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
0N/A *
2722N/A * @param owner the owner {@code Dialog} from which the dialog is displayed
2722N/A * or {@code null} if this dialog has no owner
2722N/A * @param title the {@code String} to display in the dialog's
0N/A * title bar
2722N/A * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
2722N/A * returns {@code true}.
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A */
0N/A public JDialog(Dialog owner, String title) {
0N/A this(owner, title, false);
0N/A }
0N/A
0N/A /**
0N/A * Creates a dialog with the specified title, modality
2722N/A * and the specified owner {@code Dialog}.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
0N/A *
2722N/A * @param owner the owner {@code Dialog} from which the dialog is displayed
2722N/A * or {@code null} if this dialog has no owner
2722N/A * @param title the {@code String} to display in the dialog's
0N/A * title bar
0N/A * @param modal specifies whether dialog blocks user input to other top-level
2722N/A * windows when shown. If {@code true}, the modality type property is set to
2722N/A * {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless
2722N/A * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
2722N/A * returns {@code true}.
0N/A * @see java.awt.Dialog.ModalityType
0N/A * @see java.awt.Dialog.ModalityType#MODELESS
0N/A * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
0N/A * @see java.awt.Dialog#setModal
0N/A * @see java.awt.Dialog#setModalityType
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A */
0N/A public JDialog(Dialog owner, String title, boolean modal) {
0N/A super(owner, title, modal);
0N/A dialogInit();
0N/A }
0N/A
0N/A /**
2722N/A * Creates a dialog with the specified title, owner {@code Dialog},
2722N/A * modality and {@code GraphicsConfiguration}.
0N/A *
0N/A * <p>
2722N/A * NOTE: Any popup components ({@code JComboBox},
2722N/A * {@code JPopupMenu}, {@code JMenuBar})
0N/A * created within a modal dialog will be forced to be lightweight.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
0N/A *
2722N/A * @param owner the owner {@code Dialog} from which the dialog is displayed
2722N/A * or {@code null} if this dialog has no owner
2722N/A * @param title the {@code String} to display in the dialog's
0N/A * title bar
0N/A * @param modal specifies whether dialog blocks user input to other top-level
2722N/A * windows when shown. If {@code true}, the modality type property is set to
2722N/A * {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless
2971N/A * @param gc the {@code GraphicsConfiguration} of the target screen device;
2971N/A * if {@code null}, the default system {@code GraphicsConfiguration}
2971N/A * is assumed
2722N/A * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
2722N/A * returns {@code true}.
0N/A * @see java.awt.Dialog.ModalityType
0N/A * @see java.awt.Dialog.ModalityType#MODELESS
0N/A * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
0N/A * @see java.awt.Dialog#setModal
0N/A * @see java.awt.Dialog#setModalityType
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A * @since 1.4
0N/A */
0N/A public JDialog(Dialog owner, String title, boolean modal,
0N/A GraphicsConfiguration gc) {
0N/A super(owner, title, modal, gc);
0N/A dialogInit();
0N/A }
0N/A
0N/A /**
3185N/A * Creates a modeless dialog with the specified {@code Window}
3185N/A * as its owner and an empty title.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
2722N/A *
2722N/A * @param owner the {@code Window} from which the dialog is displayed or
2722N/A * {@code null} if this dialog has no owner
0N/A *
2722N/A * @throws IllegalArgumentException
2722N/A * if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog}
2722N/A * or {@link java.awt.Frame Frame}
2722N/A * @throws IllegalArgumentException
2722N/A * if the {@code owner}'s {@code GraphicsConfiguration} is not from a screen device
2722N/A * @throws HeadlessException
2722N/A * when {@code GraphicsEnvironment.isHeadless()} returns {@code true}
0N/A *
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A *
0N/A * @since 1.6
0N/A */
0N/A public JDialog(Window owner) {
0N/A this(owner, Dialog.ModalityType.MODELESS);
0N/A }
0N/A
0N/A /**
3185N/A * Creates a dialog with an empty title and the specified modality and
3185N/A * {@code Window} as its owner.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
0N/A *
2722N/A * @param owner the {@code Window} from which the dialog is displayed or
2722N/A * {@code null} if this dialog has no owner
0N/A * @param modalityType specifies whether dialog blocks input to other
2722N/A * windows when shown. {@code null} value and unsupported modality
2722N/A * types are equivalent to {@code MODELESS}
2722N/A *
2722N/A * @throws IllegalArgumentException
2722N/A * if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog}
2722N/A * or {@link java.awt.Frame Frame}
2722N/A * @throws IllegalArgumentException
2722N/A * if the {@code owner}'s {@code GraphicsConfiguration} is not from a screen device
2722N/A * @throws HeadlessException
2722N/A * when {@code GraphicsEnvironment.isHeadless()} returns {@code true}
2722N/A * @throws SecurityException
2722N/A * if the calling thread does not have permission to create modal dialogs
2722N/A * with the given {@code modalityType}
0N/A *
0N/A * @see java.awt.Dialog.ModalityType
0N/A * @see java.awt.Dialog#setModal
0N/A * @see java.awt.Dialog#setModalityType
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A *
0N/A * @since 1.6
0N/A */
0N/A public JDialog(Window owner, ModalityType modalityType) {
3185N/A this(owner, "", modalityType);
0N/A }
0N/A
0N/A /**
0N/A * Creates a modeless dialog with the specified title and owner
2722N/A * {@code Window}.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
2722N/A *
2722N/A * @param owner the {@code Window} from which the dialog is displayed or
2722N/A * {@code null} if this dialog has no owner
2722N/A * @param title the {@code String} to display in the dialog's
2722N/A * title bar or {@code null} if the dialog has no title
0N/A *
2722N/A * @throws IllegalArgumentException
2722N/A * if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog}
2722N/A * or {@link java.awt.Frame Frame}
2722N/A * @throws IllegalArgumentException
2722N/A * if the {@code owner}'s {@code GraphicsConfiguration} is not from a screen device
2722N/A * @throws HeadlessException
2722N/A * when {@code GraphicsEnvironment.isHeadless()} returns {@code true}
0N/A *
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A *
0N/A * @since 1.6
0N/A */
0N/A public JDialog(Window owner, String title) {
0N/A this(owner, title, Dialog.ModalityType.MODELESS);
0N/A }
0N/A
0N/A /**
2722N/A * Creates a dialog with the specified title, owner {@code Window} and
0N/A * modality.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
2722N/A *
2722N/A * @param owner the {@code Window} from which the dialog is displayed or
2722N/A * {@code null} if this dialog has no owner
2722N/A * @param title the {@code String} to display in the dialog's
2722N/A * title bar or {@code null} if the dialog has no title
2722N/A * @param modalityType specifies whether dialog blocks input to other
2722N/A * windows when shown. {@code null} value and unsupported modality
2722N/A * types are equivalent to {@code MODELESS}
0N/A *
2722N/A * @throws IllegalArgumentException
2722N/A * if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog}
2722N/A * or {@link java.awt.Frame Frame}
2722N/A * @throws IllegalArgumentException
2722N/A * if the {@code owner}'s {@code GraphicsConfiguration} is not from a screen device
2722N/A * @throws HeadlessException
2722N/A * when {@code GraphicsEnvironment.isHeadless()} returns {@code true}
2722N/A * @throws SecurityException
2722N/A * if the calling thread does not have permission to create modal dialogs
2722N/A * with the given {@code modalityType}
0N/A *
0N/A * @see java.awt.Dialog.ModalityType
0N/A * @see java.awt.Dialog#setModal
0N/A * @see java.awt.Dialog#setModalityType
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A *
0N/A * @since 1.6
0N/A */
0N/A public JDialog(Window owner, String title, Dialog.ModalityType modalityType) {
0N/A super(owner, title, modalityType);
0N/A dialogInit();
0N/A }
0N/A
0N/A /**
2722N/A * Creates a dialog with the specified title, owner {@code Window},
2722N/A * modality and {@code GraphicsConfiguration}.
0N/A * <p>
2722N/A * NOTE: Any popup components ({@code JComboBox},
2722N/A * {@code JPopupMenu}, {@code JMenuBar})
0N/A * created within a modal dialog will be forced to be lightweight.
0N/A * <p>
0N/A * This constructor sets the component's locale property to the value
2722N/A * returned by {@code JComponent.getDefaultLocale}.
0N/A *
2722N/A * @param owner the {@code Window} from which the dialog is displayed or
2722N/A * {@code null} if this dialog has no owner
2722N/A * @param title the {@code String} to display in the dialog's
2722N/A * title bar or {@code null} if the dialog has no title
0N/A * @param modalityType specifies whether dialog blocks input to other
2722N/A * windows when shown. {@code null} value and unsupported modality
2722N/A * types are equivalent to {@code MODELESS}
2722N/A * @param gc the {@code GraphicsConfiguration} of the target screen device;
2971N/A * if {@code null}, the default system {@code GraphicsConfiguration}
2971N/A * is assumed
2722N/A * @throws IllegalArgumentException
2722N/A * if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog}
2722N/A * or {@link java.awt.Frame Frame}
2722N/A * @throws IllegalArgumentException
2722N/A * if the {@code owner}'s {@code GraphicsConfiguration} is not from a screen device
2722N/A * @throws HeadlessException
2722N/A * when {@code GraphicsEnvironment.isHeadless()} returns {@code true}
2722N/A * @throws SecurityException
2722N/A * if the calling thread does not have permission to create modal dialogs
2722N/A * with the given {@code modalityType}
0N/A *
0N/A * @see java.awt.Dialog.ModalityType
0N/A * @see java.awt.Dialog#setModal
0N/A * @see java.awt.Dialog#setModalityType
0N/A * @see java.awt.GraphicsEnvironment#isHeadless
0N/A * @see JComponent#getDefaultLocale
0N/A *
0N/A * @since 1.6
0N/A */
0N/A public JDialog(Window owner, String title, Dialog.ModalityType modalityType,
0N/A GraphicsConfiguration gc) {
0N/A super(owner, title, modalityType, gc);
0N/A dialogInit();
0N/A }
0N/A
0N/A /**
2722N/A * Called by the constructors to init the {@code JDialog} properly.
0N/A */
0N/A protected void dialogInit() {
0N/A enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK);
0N/A setLocale( JComponent.getDefaultLocale() );
0N/A setRootPane(createRootPane());
0N/A setRootPaneCheckingEnabled(true);
0N/A if (JDialog.isDefaultLookAndFeelDecorated()) {
0N/A boolean supportsWindowDecorations =
0N/A UIManager.getLookAndFeel().getSupportsWindowDecorations();
0N/A if (supportsWindowDecorations) {
0N/A setUndecorated(true);
0N/A getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
0N/A }
0N/A }
4875N/A sun.awt.SunToolkit.checkAndSetPolicy(this);
0N/A }
0N/A
0N/A /**
0N/A * Called by the constructor methods to create the default
2722N/A * {@code rootPane}.
0N/A */
0N/A protected JRootPane createRootPane() {
0N/A JRootPane rp = new JRootPane();
0N/A // NOTE: this uses setOpaque vs LookAndFeel.installProperty as there
0N/A // is NO reason for the RootPane not to be opaque. For painting to
0N/A // work the contentPane must be opaque, therefor the RootPane can
0N/A // also be opaque.
0N/A rp.setOpaque(true);
0N/A return rp;
0N/A }
0N/A
0N/A /**
0N/A * Handles window events depending on the state of the
2722N/A * {@code defaultCloseOperation} property.
0N/A *
0N/A * @see #setDefaultCloseOperation
0N/A */
0N/A protected void processWindowEvent(WindowEvent e) {
0N/A super.processWindowEvent(e);
0N/A
0N/A if (e.getID() == WindowEvent.WINDOW_CLOSING) {
0N/A switch(defaultCloseOperation) {
0N/A case HIDE_ON_CLOSE:
0N/A setVisible(false);
0N/A break;
0N/A case DISPOSE_ON_CLOSE:
0N/A dispose();
0N/A break;
0N/A case DO_NOTHING_ON_CLOSE:
0N/A default:
0N/A break;
0N/A }
0N/A }
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Sets the operation that will happen by default when
0N/A * the user initiates a "close" on this dialog.
0N/A * You must specify one of the following choices:
0N/A * <p>
0N/A * <ul>
2722N/A * <li>{@code DO_NOTHING_ON_CLOSE}
2722N/A * (defined in {@code WindowConstants}):
0N/A * Don't do anything; require the
2722N/A * program to handle the operation in the {@code windowClosing}
2722N/A * method of a registered {@code WindowListener} object.
0N/A *
2722N/A * <li>{@code HIDE_ON_CLOSE}
2722N/A * (defined in {@code WindowConstants}):
0N/A * Automatically hide the dialog after
2722N/A * invoking any registered {@code WindowListener}
0N/A * objects.
0N/A *
2722N/A * <li>{@code DISPOSE_ON_CLOSE}
2722N/A * (defined in {@code WindowConstants}):
0N/A * Automatically hide and dispose the
2722N/A * dialog after invoking any registered {@code WindowListener}
0N/A * objects.
0N/A * </ul>
0N/A * <p>
2722N/A * The value is set to {@code HIDE_ON_CLOSE} by default. Changes
0N/A * to the value of this property cause the firing of a property
0N/A * change event, with property name "defaultCloseOperation".
0N/A * <p>
0N/A * <b>Note</b>: When the last displayable window within the
0N/A * Java virtual machine (VM) is disposed of, the VM may
0N/A * terminate. See <a href="../../java/awt/doc-files/AWTThreadIssues.html">
0N/A * AWT Threading Issues</a> for more information.
0N/A *
0N/A * @param operation the operation which should be performed when the
0N/A * user closes the dialog
0N/A * @throws IllegalArgumentException if defaultCloseOperation value
0N/A * isn't one of the above valid values
0N/A * @see #addWindowListener
0N/A * @see #getDefaultCloseOperation
0N/A * @see WindowConstants
0N/A *
0N/A * @beaninfo
0N/A * preferred: true
0N/A * bound: true
0N/A * enum: DO_NOTHING_ON_CLOSE WindowConstants.DO_NOTHING_ON_CLOSE
0N/A * HIDE_ON_CLOSE WindowConstants.HIDE_ON_CLOSE
0N/A * DISPOSE_ON_CLOSE WindowConstants.DISPOSE_ON_CLOSE
0N/A * description: The dialog's default close operation.
0N/A */
0N/A public void setDefaultCloseOperation(int operation) {
0N/A if (operation != DO_NOTHING_ON_CLOSE &&
0N/A operation != HIDE_ON_CLOSE &&
0N/A operation != DISPOSE_ON_CLOSE) {
0N/A throw new IllegalArgumentException("defaultCloseOperation must be one of: DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, or DISPOSE_ON_CLOSE");
0N/A }
0N/A
0N/A int oldValue = this.defaultCloseOperation;
0N/A this.defaultCloseOperation = operation;
0N/A firePropertyChange("defaultCloseOperation", oldValue, operation);
0N/A }
0N/A
0N/A /**
0N/A * Returns the operation which occurs when the user
0N/A * initiates a "close" on this dialog.
0N/A *
0N/A * @return an integer indicating the window-close operation
0N/A * @see #setDefaultCloseOperation
0N/A */
0N/A public int getDefaultCloseOperation() {
0N/A return defaultCloseOperation;
0N/A }
0N/A
0N/A /**
0N/A * Sets the {@code transferHandler} property, which is a mechanism to
0N/A * support transfer of data into this component. Use {@code null}
0N/A * if the component does not support data transfer operations.
0N/A * <p>
0N/A * If the system property {@code suppressSwingDropSupport} is {@code false}
0N/A * (the default) and the current drop target on this component is either
0N/A * {@code null} or not a user-set drop target, this method will change the
0N/A * drop target as follows: If {@code newHandler} is {@code null} it will
0N/A * clear the drop target. If not {@code null} it will install a new
0N/A * {@code DropTarget}.
0N/A * <p>
0N/A * Note: When used with {@code JDialog}, {@code TransferHandler} only
0N/A * provides data import capability, as the data export related methods
0N/A * are currently typed to {@code JComponent}.
0N/A * <p>
0N/A * Please see
0N/A * <a href="http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html">
0N/A * How to Use Drag and Drop and Data Transfer</a>, a section in
0N/A * <em>The Java Tutorial</em>, for more information.
0N/A *
0N/A * @param newHandler the new {@code TransferHandler}
0N/A *
0N/A * @see TransferHandler
0N/A * @see #getTransferHandler
0N/A * @see java.awt.Component#setDropTarget
0N/A * @since 1.6
0N/A *
0N/A * @beaninfo
0N/A * bound: true
0N/A * hidden: true
0N/A * description: Mechanism for transfer of data into the component
0N/A */
0N/A public void setTransferHandler(TransferHandler newHandler) {
0N/A TransferHandler oldHandler = transferHandler;
0N/A transferHandler = newHandler;
0N/A SwingUtilities.installSwingDropTargetAsNecessary(this, transferHandler);
0N/A firePropertyChange("transferHandler", oldHandler, newHandler);
0N/A }
0N/A
0N/A /**
2722N/A * Gets the {@code transferHandler} property.
0N/A *
2722N/A * @return the value of the {@code transferHandler} property
0N/A *
0N/A * @see TransferHandler
0N/A * @see #setTransferHandler
0N/A * @since 1.6
0N/A */
0N/A public TransferHandler getTransferHandler() {
0N/A return transferHandler;
0N/A }
0N/A
0N/A /**
2722N/A * Calls {@code paint(g)}. This method was overridden to
0N/A * prevent an unnecessary call to clear the background.
0N/A *
2722N/A * @param g the {@code Graphics} context in which to paint
0N/A */
0N/A public void update(Graphics g) {
0N/A paint(g);
0N/A }
0N/A
0N/A /**
0N/A * Sets the menubar for this dialog.
0N/A *
0N/A * @param menu the menubar being placed in the dialog
0N/A *
0N/A * @see #getJMenuBar
0N/A *
0N/A * @beaninfo
0N/A * hidden: true
0N/A * description: The menubar for accessing pulldown menus from this dialog.
0N/A */
0N/A public void setJMenuBar(JMenuBar menu) {
0N/A getRootPane().setMenuBar(menu);
0N/A }
0N/A
0N/A /**
0N/A * Returns the menubar set on this dialog.
0N/A *
0N/A * @see #setJMenuBar
0N/A */
0N/A public JMenuBar getJMenuBar() {
0N/A return getRootPane().getMenuBar();
0N/A }
0N/A
0N/A
0N/A /**
2722N/A * Returns whether calls to {@code add} and
2722N/A * {@code setLayout} are forwarded to the {@code contentPane}.
0N/A *
2722N/A * @return true if {@code add} and {@code setLayout}
0N/A * are fowarded; false otherwise
0N/A *
0N/A * @see #addImpl
0N/A * @see #setLayout
0N/A * @see #setRootPaneCheckingEnabled
0N/A * @see javax.swing.RootPaneContainer
0N/A */
0N/A protected boolean isRootPaneCheckingEnabled() {
0N/A return rootPaneCheckingEnabled;
0N/A }
0N/A
0N/A
0N/A /**
2722N/A * Sets whether calls to {@code add} and
2722N/A * {@code setLayout} are forwarded to the {@code contentPane}.
0N/A *
2722N/A * @param enabled true if {@code add} and {@code setLayout}
0N/A * are forwarded, false if they should operate directly on the
2722N/A * {@code JDialog}.
0N/A *
0N/A * @see #addImpl
0N/A * @see #setLayout
0N/A * @see #isRootPaneCheckingEnabled
0N/A * @see javax.swing.RootPaneContainer
0N/A * @beaninfo
0N/A * hidden: true
0N/A * description: Whether the add and setLayout methods are forwarded
0N/A */
0N/A protected void setRootPaneCheckingEnabled(boolean enabled) {
0N/A rootPaneCheckingEnabled = enabled;
0N/A }
0N/A
0N/A /**
2722N/A * Adds the specified child {@code Component}.
0N/A * This method is overridden to conditionally forward calls to the
2722N/A * {@code contentPane}.
2722N/A * By default, children are added to the {@code contentPane} instead
0N/A * of the frame, refer to {@link javax.swing.RootPaneContainer} for
0N/A * details.
0N/A *
0N/A * @param comp the component to be enhanced
0N/A * @param constraints the constraints to be respected
0N/A * @param index the index
2722N/A * @throws IllegalArgumentException if {@code index} is invalid
2722N/A * @throws IllegalArgumentException if adding the container's parent
0N/A * to itself
2722N/A * @throws IllegalArgumentException if adding a window to a container
0N/A *
0N/A * @see #setRootPaneCheckingEnabled
0N/A * @see javax.swing.RootPaneContainer
0N/A */
0N/A protected void addImpl(Component comp, Object constraints, int index)
0N/A {
0N/A if(isRootPaneCheckingEnabled()) {
0N/A getContentPane().add(comp, constraints, index);
0N/A }
0N/A else {
0N/A super.addImpl(comp, constraints, index);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Removes the specified component from the container. If
2722N/A * {@code comp} is not the {@code rootPane}, this will forward
2722N/A * the call to the {@code contentPane}. This will do nothing if
2722N/A * {@code comp} is not a child of the {@code JDialog} or
2722N/A * {@code contentPane}.
0N/A *
0N/A * @param comp the component to be removed
2722N/A * @throws NullPointerException if {@code comp} is null
0N/A * @see #add
0N/A * @see javax.swing.RootPaneContainer
0N/A */
0N/A public void remove(Component comp) {
0N/A if (comp == rootPane) {
0N/A super.remove(comp);
0N/A } else {
0N/A getContentPane().remove(comp);
0N/A }
0N/A }
0N/A
0N/A
0N/A /**
2722N/A * Sets the {@code LayoutManager}.
0N/A * Overridden to conditionally forward the call to the
2722N/A * {@code contentPane}.
0N/A * Refer to {@link javax.swing.RootPaneContainer} for
0N/A * more information.
0N/A *
2722N/A * @param manager the {@code LayoutManager}
0N/A * @see #setRootPaneCheckingEnabled
0N/A * @see javax.swing.RootPaneContainer
0N/A */
0N/A public void setLayout(LayoutManager manager) {
0N/A if(isRootPaneCheckingEnabled()) {
0N/A getContentPane().setLayout(manager);
0N/A }
0N/A else {
0N/A super.setLayout(manager);
0N/A }
0N/A }
0N/A
0N/A
0N/A /**
2722N/A * Returns the {@code rootPane} object for this dialog.
0N/A *
0N/A * @see #setRootPane
0N/A * @see RootPaneContainer#getRootPane
0N/A */
0N/A public JRootPane getRootPane() {
0N/A return rootPane;
0N/A }
0N/A
0N/A
0N/A /**
2722N/A * Sets the {@code rootPane} property.
0N/A * This method is called by the constructor.
0N/A *
2722N/A * @param root the {@code rootPane} object for this dialog
0N/A *
0N/A * @see #getRootPane
0N/A *
0N/A * @beaninfo
0N/A * hidden: true
0N/A * description: the RootPane object for this dialog.
0N/A */
0N/A protected void setRootPane(JRootPane root) {
0N/A if(rootPane != null) {
0N/A remove(rootPane);
0N/A }
0N/A rootPane = root;
0N/A if(rootPane != null) {
0N/A boolean checkingEnabled = isRootPaneCheckingEnabled();
0N/A try {
0N/A setRootPaneCheckingEnabled(false);
0N/A add(rootPane, BorderLayout.CENTER);
0N/A }
0N/A finally {
0N/A setRootPaneCheckingEnabled(checkingEnabled);
0N/A }
0N/A }
0N/A }
0N/A
0N/A
0N/A /**
2722N/A * Returns the {@code contentPane} object for this dialog.
0N/A *
2722N/A * @return the {@code contentPane} property
0N/A *
0N/A * @see #setContentPane
0N/A * @see RootPaneContainer#getContentPane
0N/A */
0N/A public Container getContentPane() {
0N/A return getRootPane().getContentPane();
0N/A }
0N/A
0N/A
0N/A /**
2722N/A * Sets the {@code contentPane} property.
0N/A * This method is called by the constructor.
0N/A * <p>
2722N/A * Swing's painting architecture requires an opaque {@code JComponent}
0N/A * in the containment hiearchy. This is typically provided by the
0N/A * content pane. If you replace the content pane it is recommended you
2722N/A * replace it with an opaque {@code JComponent}.
0N/A * @see JRootPane
0N/A *
2722N/A * @param contentPane the {@code contentPane} object for this dialog
0N/A *
2722N/A * @throws java.awt.IllegalComponentStateException (a runtime
2722N/A * exception) if the content pane parameter is {@code null}
0N/A * @see #getContentPane
0N/A * @see RootPaneContainer#setContentPane
0N/A *
0N/A * @beaninfo
0N/A * hidden: true
0N/A * description: The client area of the dialog where child
0N/A * components are normally inserted.
0N/A */
0N/A public void setContentPane(Container contentPane) {
0N/A getRootPane().setContentPane(contentPane);
0N/A }
0N/A
0N/A /**
2722N/A * Returns the {@code layeredPane} object for this dialog.
0N/A *
2722N/A * @return the {@code layeredPane} property
0N/A *
0N/A * @see #setLayeredPane
0N/A * @see RootPaneContainer#getLayeredPane
0N/A */
0N/A public JLayeredPane getLayeredPane() {
0N/A return getRootPane().getLayeredPane();
0N/A }
0N/A
0N/A /**
2722N/A * Sets the {@code layeredPane} property.
0N/A * This method is called by the constructor.
0N/A *
2722N/A * @param layeredPane the new {@code layeredPane} property
0N/A *
2722N/A * @throws java.awt.IllegalComponentStateException (a runtime
0N/A * exception) if the layered pane parameter is null
0N/A * @see #getLayeredPane
0N/A * @see RootPaneContainer#setLayeredPane
0N/A *
0N/A * @beaninfo
0N/A * hidden: true
0N/A * description: The pane which holds the various dialog layers.
0N/A */
0N/A public void setLayeredPane(JLayeredPane layeredPane) {
0N/A getRootPane().setLayeredPane(layeredPane);
0N/A }
0N/A
0N/A /**
2722N/A * Returns the {@code glassPane} object for this dialog.
0N/A *
2722N/A * @return the {@code glassPane} property
0N/A *
0N/A * @see #setGlassPane
0N/A * @see RootPaneContainer#getGlassPane
0N/A */
0N/A public Component getGlassPane() {
0N/A return getRootPane().getGlassPane();
0N/A }
0N/A
0N/A /**
2722N/A * Sets the {@code glassPane} property.
0N/A * This method is called by the constructor.
0N/A *
2722N/A * @param glassPane the {@code glassPane} object for this dialog
0N/A * @see #getGlassPane
0N/A * @see RootPaneContainer#setGlassPane
0N/A *
0N/A * @beaninfo
0N/A * hidden: true
0N/A * description: A transparent pane used for menu rendering.
0N/A */
0N/A public void setGlassPane(Component glassPane) {
0N/A getRootPane().setGlassPane(glassPane);
0N/A }
0N/A
0N/A /**
0N/A * {@inheritDoc}
0N/A *
0N/A * @since 1.6
0N/A */
0N/A public Graphics getGraphics() {
0N/A JComponent.getGraphicsInvoked(this);
0N/A return super.getGraphics();
0N/A }
0N/A
0N/A /**
0N/A * Repaints the specified rectangle of this component within
2722N/A * {@code time} milliseconds. Refer to {@code RepaintManager}
0N/A * for details on how the repaint is handled.
0N/A *
0N/A * @param time maximum time in milliseconds before update
0N/A * @param x the <i>x</i> coordinate
0N/A * @param y the <i>y</i> coordinate
0N/A * @param width the width
0N/A * @param height the height
0N/A * @see RepaintManager
0N/A * @since 1.6
0N/A */
0N/A public void repaint(long time, int x, int y, int width, int height) {
0N/A if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
0N/A RepaintManager.currentManager(this).addDirtyRegion(
0N/A this, x, y, width, height);
0N/A }
0N/A else {
0N/A super.repaint(time, x, y, width, height);
0N/A }
0N/A }
0N/A
0N/A /**
2722N/A * Provides a hint as to whether or not newly created {@code JDialog}s
0N/A * should have their Window decorations (such as borders, widgets to
0N/A * close the window, title...) provided by the current look
2722N/A * and feel. If {@code defaultLookAndFeelDecorated} is true,
2722N/A * the current {@code LookAndFeel} supports providing window
0N/A * decorations, and the current window manager supports undecorated
2722N/A * windows, then newly created {@code JDialog}s will have their
2722N/A * Window decorations provided by the current {@code LookAndFeel}.
2722N/A * Otherwise, newly created {@code JDialog}s will have their
0N/A * Window decorations provided by the current window manager.
0N/A * <p>
0N/A * You can get the same effect on a single JDialog by doing the following:
0N/A * <pre>
0N/A * JDialog dialog = new JDialog();
0N/A * dialog.setUndecorated(true);
0N/A * dialog.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
0N/A * </pre>
0N/A *
0N/A * @param defaultLookAndFeelDecorated A hint as to whether or not current
0N/A * look and feel should provide window decorations
0N/A * @see javax.swing.LookAndFeel#getSupportsWindowDecorations
0N/A * @since 1.4
0N/A */
0N/A public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated) {
0N/A if (defaultLookAndFeelDecorated) {
0N/A SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.TRUE);
0N/A } else {
0N/A SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.FALSE);
0N/A }
0N/A }
0N/A
0N/A /**
2722N/A * Returns true if newly created {@code JDialog}s should have their
0N/A * Window decorations provided by the current look and feel. This is only
0N/A * a hint, as certain look and feels may not support this feature.
0N/A *
0N/A * @return true if look and feel should provide Window decorations.
0N/A * @since 1.4
0N/A */
0N/A public static boolean isDefaultLookAndFeelDecorated() {
0N/A Boolean defaultLookAndFeelDecorated =
0N/A (Boolean) SwingUtilities.appContextGet(defaultLookAndFeelDecoratedKey);
0N/A if (defaultLookAndFeelDecorated == null) {
0N/A defaultLookAndFeelDecorated = Boolean.FALSE;
0N/A }
0N/A return defaultLookAndFeelDecorated.booleanValue();
0N/A }
0N/A
0N/A /**
2722N/A * Returns a string representation of this {@code JDialog}.
0N/A * This method
0N/A * is intended to be used only for debugging purposes, and the
0N/A * content and format of the returned string may vary between
0N/A * implementations. The returned string may be empty but may not
2722N/A * be {@code null}.
0N/A *
2722N/A * @return a string representation of this {@code JDialog}.
0N/A */
0N/A protected String paramString() {
0N/A String defaultCloseOperationString;
0N/A if (defaultCloseOperation == HIDE_ON_CLOSE) {
0N/A defaultCloseOperationString = "HIDE_ON_CLOSE";
0N/A } else if (defaultCloseOperation == DISPOSE_ON_CLOSE) {
0N/A defaultCloseOperationString = "DISPOSE_ON_CLOSE";
0N/A } else if (defaultCloseOperation == DO_NOTHING_ON_CLOSE) {
0N/A defaultCloseOperationString = "DO_NOTHING_ON_CLOSE";
0N/A } else defaultCloseOperationString = "";
0N/A String rootPaneString = (rootPane != null ?
0N/A rootPane.toString() : "");
0N/A String rootPaneCheckingEnabledString = (rootPaneCheckingEnabled ?
0N/A "true" : "false");
0N/A
0N/A return super.paramString() +
0N/A ",defaultCloseOperation=" + defaultCloseOperationString +
0N/A ",rootPane=" + rootPaneString +
0N/A ",rootPaneCheckingEnabled=" + rootPaneCheckingEnabledString;
0N/A }
0N/A
0N/A
0N/A/////////////////
0N/A// Accessibility support
0N/A////////////////
0N/A
0N/A protected AccessibleContext accessibleContext = null;
0N/A
0N/A /**
0N/A * Gets the AccessibleContext associated with this JDialog.
0N/A * For JDialogs, the AccessibleContext takes the form of an
0N/A * AccessibleJDialog.
0N/A * A new AccessibleJDialog instance is created if necessary.
0N/A *
0N/A * @return an AccessibleJDialog that serves as the
0N/A * AccessibleContext of this JDialog
0N/A */
0N/A public AccessibleContext getAccessibleContext() {
0N/A if (accessibleContext == null) {
0N/A accessibleContext = new AccessibleJDialog();
0N/A }
0N/A return accessibleContext;
0N/A }
0N/A
0N/A /**
0N/A * This class implements accessibility support for the
2722N/A * {@code JDialog} class. It provides an implementation of the
0N/A * Java Accessibility API appropriate to dialog user-interface
0N/A * elements.
0N/A */
0N/A protected class AccessibleJDialog extends AccessibleAWTDialog {
0N/A
0N/A // AccessibleContext methods
0N/A //
0N/A /**
0N/A * Get the accessible name of this object.
0N/A *
0N/A * @return the localized name of the object -- can be null if this
0N/A * object does not have a name
0N/A */
0N/A public String getAccessibleName() {
0N/A if (accessibleName != null) {
0N/A return accessibleName;
0N/A } else {
0N/A if (getTitle() == null) {
0N/A return super.getAccessibleName();
0N/A } else {
0N/A return getTitle();
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Get the state of this object.
0N/A *
0N/A * @return an instance of AccessibleStateSet containing the current
0N/A * state set of the object
0N/A * @see AccessibleState
0N/A */
0N/A public AccessibleStateSet getAccessibleStateSet() {
0N/A AccessibleStateSet states = super.getAccessibleStateSet();
0N/A
0N/A if (isResizable()) {
0N/A states.add(AccessibleState.RESIZABLE);
0N/A }
0N/A if (getFocusOwner() != null) {
0N/A states.add(AccessibleState.ACTIVE);
0N/A }
0N/A if (isModal()) {
0N/A states.add(AccessibleState.MODAL);
0N/A }
0N/A return states;
0N/A }
0N/A
0N/A } // inner class AccessibleJDialog
0N/A}