jdk/src/share/classes/javax/swing/JDialog.java
author ant
Thu, 17 May 2012 21:48:57 +0400
changeset 12661 6cf8b7116579
parent 7500 dec4b445efc6
child 20455 f6f9a0c2796b
permissions -rw-r--r--
7125044: [macosx] Test failure because Component.transferFocus() works differently in applet and application. Summary: forward port from 7u4 Reviewed-by: art
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
     2
 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 1639
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package javax.swing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * The main class for creating a dialog window. You can use this class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * to create a custom dialog, or invoke the many class methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * in {@link JOptionPane} to create a variety of standard dialogs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * For information about creating dialogs, see
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * <em>The Java Tutorial</em> section
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 href="http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html">How
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * to Make Dialogs</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    43
 * The {@code JDialog} component contains a {@code JRootPane}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * as its only child.
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    45
 * The {@code contentPane} should be the parent of any children of the
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    46
 * {@code JDialog}.
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    47
 * As a convenience {@code add} and its variants, {@code remove} and
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    48
 * {@code setLayout} have been overridden to forward to the
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    49
 * {@code contentPane} as necessary. This means you can write:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *       dialog.add(child);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * And the child will be added to the contentPane.
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    54
 * The {@code contentPane} is always non-{@code null}.
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    55
 * Attempting to set it to {@code null} generates an exception.
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    56
 * The default {@code contentPane} has a {@code BorderLayout}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * manager set on it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * Refer to {@link javax.swing.RootPaneContainer}
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    59
 * for details on adding, removing and setting the {@code LayoutManager}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    60
 * of a {@code JDialog}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <p>
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    62
 * Please see the {@code JRootPane} documentation for a complete
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    63
 * description of the {@code contentPane}, {@code glassPane},
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    64
 * and {@code layeredPane} components.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <p>
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    66
 * In a multi-screen environment, you can create a {@code JDialog}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * on a different screen device than its owner.  See {@link java.awt.Frame} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * <strong>Warning:</strong> Swing is not thread safe. For more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * information see <a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * href="package-summary.html#threading">Swing's Threading
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * Policy</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * <strong>Warning:</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * Serialized objects of this class will not be compatible with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * future Swing releases. The current serialization support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * appropriate for short term storage or RMI between applications running
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * the same version of Swing.  As of 1.4, support for long term storage
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * of all JavaBeans<sup><font size="-2">TM</font></sup>
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
    81
 * has been added to the {@code java.beans} package.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * Please see {@link java.beans.XMLEncoder}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * @see JOptionPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * @see JRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 *      attribute: isContainer true
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 *      attribute: containerDelegate getContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 *    description: A toplevel window for creating dialog boxes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * @author David Kloba
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * @author James Gosling
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * @author Scott Violet
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
public class JDialog extends Dialog implements WindowConstants,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                                               Accessible,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                                               RootPaneContainer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                               TransferHandler.HasGetTransferHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * Key into the AppContext, used to check if should provide decorations
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * by default.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    private static final Object defaultLookAndFeelDecoratedKey =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            new StringBuffer("JDialog.defaultLookAndFeelDecorated");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    private int defaultCloseOperation = HIDE_ON_CLOSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @see #getRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @see #setRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    protected JRootPane rootPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   118
     * If true then calls to {@code add} and {@code setLayout}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   119
     * will be forwarded to the {@code contentPane}. This is initially
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   120
     * false, but is set to true when the {@code JDialog} is constructed.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @see #isRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    protected boolean rootPaneCheckingEnabled = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   129
     * The {@code TransferHandler} for this dialog.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    private TransferHandler transferHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * Creates a modeless dialog without a title and without a specified
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   135
     * {@code Frame} owner.  A shared, hidden frame will be
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * set as the owner of the dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   139
     * returned by {@code JComponent.getDefaultLocale}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * NOTE: This constructor does not allow you to create an unowned
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   142
     * {@code JDialog}. To create an unowned {@code JDialog}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   143
     * you must use either the {@code JDialog(Window)} or
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   144
     * {@code JDialog(Dialog)} constructor with an argument of
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   145
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   147
     * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   148
     *     returns {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public JDialog() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        this((Frame)null, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
7500
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 7012
diff changeset
   157
     * Creates a modeless dialog with the specified {@code Frame}
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 7012
diff changeset
   158
     * as its owner and an empty title. If {@code owner}
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   159
     * is {@code null}, a shared, hidden frame will be set as the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * owner of the dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   163
     * returned by {@code JComponent.getDefaultLocale}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * NOTE: This constructor does not allow you to create an unowned
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   166
     * {@code JDialog}. To create an unowned {@code JDialog}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   167
     * you must use either the {@code JDialog(Window)} or
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   168
     * {@code JDialog(Dialog)} constructor with an argument of
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   169
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   171
     * @param owner the {@code Frame} from which the dialog is displayed
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   172
     * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   173
     *     returns {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    public JDialog(Frame owner) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        this(owner, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    /**
7500
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 7012
diff changeset
   182
     * Creates a dialog with an empty title and the specified modality and
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 7012
diff changeset
   183
     * {@code Frame} as its owner. If {@code owner} is {@code null},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * a shared, hidden frame will be set as the owner of the dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   187
     * returned by {@code JComponent.getDefaultLocale}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * NOTE: This constructor does not allow you to create an unowned
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   190
     * {@code JDialog}. To create an unowned {@code JDialog}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   191
     * you must use either the {@code JDialog(Window)} or
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   192
     * {@code JDialog(Dialog)} constructor with an argument of
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   193
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   195
     * @param owner the {@code Frame} from which the dialog is displayed
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @param modal specifies whether dialog blocks user input to other top-level
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   197
     *     windows when shown. If {@code true}, the modality type property is set to
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   198
     *     {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless.
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   199
     * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   200
     *     returns {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    public JDialog(Frame owner, boolean modal) {
7500
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 7012
diff changeset
   205
        this(owner, "", modal);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * Creates a modeless dialog with the specified title and
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   210
     * with the specified owner frame.  If {@code owner}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   211
     * is {@code null}, a shared, hidden frame will be set as the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * owner of the dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   215
     * returned by {@code JComponent.getDefaultLocale}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * NOTE: This constructor does not allow you to create an unowned
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   218
     * {@code JDialog}. To create an unowned {@code JDialog}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   219
     * you must use either the {@code JDialog(Window)} or
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   220
     * {@code JDialog(Dialog)} constructor with an argument of
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   221
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   223
     * @param owner the {@code Frame} from which the dialog is displayed
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   224
     * @param title  the {@code String} to display in the dialog's
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     *                  title bar
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   226
     * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   227
     *     returns {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    public JDialog(Frame owner, String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        this(owner, title, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   236
     * Creates a dialog with the specified title, owner {@code Frame}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   237
     * and modality. If {@code owner} is {@code null},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * a shared, hidden frame will be set as the owner of this dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   241
     * returned by {@code JComponent.getDefaultLocale}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * <p>
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   243
     * NOTE: Any popup components ({@code JComboBox},
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   244
     * {@code JPopupMenu}, {@code JMenuBar})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * created within a modal dialog will be forced to be lightweight.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * NOTE: This constructor does not allow you to create an unowned
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   248
     * {@code JDialog}. To create an unowned {@code JDialog}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   249
     * you must use either the {@code JDialog(Window)} or
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   250
     * {@code JDialog(Dialog)} constructor with an argument of
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   251
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   253
     * @param owner the {@code Frame} from which the dialog is displayed
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   254
     * @param title  the {@code String} to display in the dialog's
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     *     title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * @param modal specifies whether dialog blocks user input to other top-level
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   257
     *     windows when shown. If {@code true}, the modality type property is set to
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   258
     *     {@code DEFAULT_MODALITY_TYPE} otherwise the dialog is modeless
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   259
     * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   260
     *     returns {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * @see java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    public JDialog(Frame owner, String title, boolean modal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        super(owner == null? SwingUtilities.getSharedOwnerFrame() : owner,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
              title, modal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        if (owner == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            WindowListener ownerShutdownListener =
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
   275
                    SwingUtilities.getSharedOwnerFrameShutdownListener();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            addWindowListener(ownerShutdownListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        dialogInit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * Creates a dialog with the specified title,
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   283
     * owner {@code Frame}, modality and {@code GraphicsConfiguration}.
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   284
     * If {@code owner} is {@code null},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * a shared, hidden frame will be set as the owner of this dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   288
     * returned by {@code JComponent.getDefaultLocale}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * <p>
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   290
     * NOTE: Any popup components ({@code JComboBox},
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   291
     * {@code JPopupMenu}, {@code JMenuBar})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * created within a modal dialog will be forced to be lightweight.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * NOTE: This constructor does not allow you to create an unowned
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   295
     * {@code JDialog}. To create an unowned {@code JDialog}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   296
     * you must use either the {@code JDialog(Window)} or
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   297
     * {@code JDialog(Dialog)} constructor with an argument of
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   298
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   300
     * @param owner the {@code Frame} from which the dialog is displayed
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   301
     * @param title  the {@code String} to display in the dialog's
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     *     title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @param modal specifies whether dialog blocks user input to other top-level
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   304
     *     windows when shown. If {@code true}, the modality type property is set to
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   305
     *     {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless.
7012
a1b12adbb080 6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents: 6511
diff changeset
   306
     * @param gc the {@code GraphicsConfiguration} of the target screen device;
a1b12adbb080 6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents: 6511
diff changeset
   307
     *     if {@code null}, the default system {@code GraphicsConfiguration}
a1b12adbb080 6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents: 6511
diff changeset
   308
     *     is assumed
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   309
     * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   310
     *     returns {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * @see java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    public JDialog(Frame owner, String title, boolean modal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                   GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        super(owner == null? SwingUtilities.getSharedOwnerFrame() : owner,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
              title, modal, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        if (owner == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            WindowListener ownerShutdownListener =
1301
15e81207e1f2 6727662: Code improvement and warnings removing from swing packages
rupashka
parents: 2
diff changeset
   326
                    SwingUtilities.getSharedOwnerFrameShutdownListener();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            addWindowListener(ownerShutdownListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        dialogInit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    /**
7500
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 7012
diff changeset
   333
     * Creates a modeless dialog with the specified {@code Dialog}
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 7012
diff changeset
   334
     * as its owner and an empty title.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   337
     * returned by {@code JComponent.getDefaultLocale}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   339
     * @param owner the owner {@code Dialog} from which the dialog is displayed
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   340
     *     or {@code null} if this dialog has no owner
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   341
     * @throws HeadlessException {@code if GraphicsEnvironment.isHeadless()}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   342
     *     returns {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    public JDialog(Dialog owner) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        this(owner, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    /**
7500
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 7012
diff changeset
   351
     * Creates a dialog with an empty title and the specified modality and
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 7012
diff changeset
   352
     * {@code Dialog} as its owner.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   355
     * returned by {@code JComponent.getDefaultLocale}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   357
     * @param owner the owner {@code Dialog} from which the dialog is displayed
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   358
     *     or {@code null} if this dialog has no owner
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @param modal specifies whether dialog blocks user input to other top-level
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   360
     *     windows when shown. If {@code true}, the modality type property is set to
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   361
     *     {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless.
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   362
     * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   363
     *     returns {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * @see java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    public JDialog(Dialog owner, boolean modal) {
7500
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 7012
diff changeset
   373
        this(owner, "", modal);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * Creates a modeless dialog with the specified title and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * with the specified owner dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   381
     * returned by {@code JComponent.getDefaultLocale}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   383
     * @param owner the owner {@code Dialog} from which the dialog is displayed
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   384
     *     or {@code null} if this dialog has no owner
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   385
     * @param title  the {@code String} to display in the dialog's
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     *                  title bar
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   387
     * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   388
     *     returns {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    public JDialog(Dialog owner, String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        this(owner, title, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * Creates a dialog with the specified title, modality
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   398
     * and the specified owner {@code Dialog}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   401
     * returned by {@code JComponent.getDefaultLocale}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   403
     * @param owner the owner {@code Dialog} from which the dialog is displayed
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   404
     *     or {@code null} if this dialog has no owner
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   405
     * @param title  the {@code String} to display in the dialog's
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     *     title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * @param modal specifies whether dialog blocks user input to other top-level
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   408
     *     windows when shown. If {@code true}, the modality type property is set to
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   409
     *     {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   410
     * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   411
     *     returns {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @see java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    public JDialog(Dialog owner, String title, boolean modal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        super(owner, title, modal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        dialogInit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   426
     * Creates a dialog with the specified title, owner {@code Dialog},
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   427
     * modality and {@code GraphicsConfiguration}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * <p>
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   430
     * NOTE: Any popup components ({@code JComboBox},
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   431
     * {@code JPopupMenu}, {@code JMenuBar})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * created within a modal dialog will be forced to be lightweight.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   435
     * returned by {@code JComponent.getDefaultLocale}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   437
     * @param owner the owner {@code Dialog} from which the dialog is displayed
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   438
     *     or {@code null} if this dialog has no owner
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   439
     * @param title  the {@code String} to display in the dialog's
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     *     title bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * @param modal specifies whether dialog blocks user input to other top-level
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   442
     *     windows when shown. If {@code true}, the modality type property is set to
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   443
     *     {@code DEFAULT_MODALITY_TYPE}, otherwise the dialog is modeless
7012
a1b12adbb080 6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents: 6511
diff changeset
   444
     * @param gc the {@code GraphicsConfiguration} of the target screen device;
a1b12adbb080 6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents: 6511
diff changeset
   445
     *     if {@code null}, the default system {@code GraphicsConfiguration}
a1b12adbb080 6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents: 6511
diff changeset
   446
     *     is assumed
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   447
     * @throws HeadlessException if {@code GraphicsEnvironment.isHeadless()}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   448
     *     returns {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * @see java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    public JDialog(Dialog owner, String title, boolean modal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
                   GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        super(owner, title, modal, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        dialogInit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    /**
7500
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 7012
diff changeset
   465
     * Creates a modeless dialog with the specified {@code Window}
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 7012
diff changeset
   466
     * as its owner and an empty title.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   469
     * returned by {@code JComponent.getDefaultLocale}.
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   470
     *
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   471
     * @param owner the {@code Window} from which the dialog is displayed or
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   472
     *     {@code null} if this dialog has no owner
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   474
     * @throws IllegalArgumentException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   475
     *     if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   476
     *     or {@link java.awt.Frame Frame}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   477
     * @throws IllegalArgumentException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   478
     *     if the {@code owner}'s {@code GraphicsConfiguration} is not from a screen device
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   479
     * @throws HeadlessException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   480
     *     when {@code GraphicsEnvironment.isHeadless()} returns {@code true}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    public JDialog(Window owner) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        this(owner, Dialog.ModalityType.MODELESS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    /**
7500
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 7012
diff changeset
   492
     * Creates a dialog with an empty title and the specified modality and
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 7012
diff changeset
   493
     * {@code Window} as its owner.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   496
     * returned by {@code JComponent.getDefaultLocale}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   498
     * @param owner the {@code Window} from which the dialog is displayed or
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   499
     *     {@code null} if this dialog has no owner
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * @param modalityType specifies whether dialog blocks input to other
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   501
     *     windows when shown. {@code null} value and unsupported modality
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   502
     *     types are equivalent to {@code MODELESS}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   503
     *
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   504
     * @throws IllegalArgumentException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   505
     *     if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   506
     *     or {@link java.awt.Frame Frame}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   507
     * @throws IllegalArgumentException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   508
     *     if the {@code owner}'s {@code GraphicsConfiguration} is not from a screen device
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   509
     * @throws HeadlessException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   510
     *     when {@code GraphicsEnvironment.isHeadless()} returns {@code true}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   511
     * @throws SecurityException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   512
     *     if the calling thread does not have permission to create modal dialogs
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   513
     *     with the given {@code modalityType}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    public JDialog(Window owner, ModalityType modalityType) {
7500
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 7012
diff changeset
   524
        this(owner, "", modalityType);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * Creates a modeless dialog with the specified title and owner
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   529
     * {@code Window}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   532
     * returned by {@code JComponent.getDefaultLocale}.
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   533
     *
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   534
     * @param owner the {@code Window} from which the dialog is displayed or
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   535
     *     {@code null} if this dialog has no owner
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   536
     * @param title the {@code String} to display in the dialog's
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   537
     *     title bar or {@code null} if the dialog has no title
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   539
     * @throws IllegalArgumentException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   540
     *     if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   541
     *     or {@link java.awt.Frame Frame}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   542
     * @throws IllegalArgumentException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   543
     *     if the {@code owner}'s {@code GraphicsConfiguration} is not from a screen device
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   544
     * @throws HeadlessException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   545
     *     when {@code GraphicsEnvironment.isHeadless()} returns {@code true}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    public JDialog(Window owner, String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        this(owner, title, Dialog.ModalityType.MODELESS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   557
     * Creates a dialog with the specified title, owner {@code Window} and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * modality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   561
     * returned by {@code JComponent.getDefaultLocale}.
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   562
     *
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   563
     * @param owner the {@code Window} from which the dialog is displayed or
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   564
     *     {@code null} if this dialog has no owner
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   565
     * @param title the {@code String} to display in the dialog's
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   566
     *     title bar or {@code null} if the dialog has no title
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   567
     * @param modalityType specifies whether dialog blocks input to other
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   568
     *     windows when shown. {@code null} value and unsupported modality
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   569
     *     types are equivalent to {@code MODELESS}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   571
     * @throws IllegalArgumentException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   572
     *     if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   573
     *     or {@link java.awt.Frame Frame}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   574
     * @throws IllegalArgumentException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   575
     *     if the {@code owner}'s {@code GraphicsConfiguration} is not from a screen device
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   576
     * @throws HeadlessException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   577
     *     when {@code GraphicsEnvironment.isHeadless()} returns {@code true}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   578
     * @throws SecurityException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   579
     *     if the calling thread does not have permission to create modal dialogs
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   580
     *     with the given {@code modalityType}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    public JDialog(Window owner, String title, Dialog.ModalityType modalityType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        super(owner, title, modalityType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        dialogInit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   596
     * Creates a dialog with the specified title, owner {@code Window},
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   597
     * modality and {@code GraphicsConfiguration}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * <p>
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   599
     * NOTE: Any popup components ({@code JComboBox},
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   600
     * {@code JPopupMenu}, {@code JMenuBar})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * created within a modal dialog will be forced to be lightweight.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * This constructor sets the component's locale property to the value
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   604
     * returned by {@code JComponent.getDefaultLocale}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   606
     * @param owner the {@code Window} from which the dialog is displayed or
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   607
     *     {@code null} if this dialog has no owner
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   608
     * @param title the {@code String} to display in the dialog's
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   609
     *     title bar or {@code null} if the dialog has no title
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * @param modalityType specifies whether dialog blocks input to other
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   611
     *     windows when shown. {@code null} value and unsupported modality
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   612
     *     types are equivalent to {@code MODELESS}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   613
     * @param gc the {@code GraphicsConfiguration} of the target screen device;
7012
a1b12adbb080 6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents: 6511
diff changeset
   614
     *     if {@code null}, the default system {@code GraphicsConfiguration}
a1b12adbb080 6659894: JDialog instance returns unexpected GraphicsConfiguration
rupashka
parents: 6511
diff changeset
   615
     *     is assumed
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   616
     * @throws IllegalArgumentException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   617
     *     if the {@code owner} is not an instance of {@link java.awt.Dialog Dialog}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   618
     *     or {@link java.awt.Frame Frame}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   619
     * @throws IllegalArgumentException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   620
     *     if the {@code owner}'s {@code GraphicsConfiguration} is not from a screen device
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   621
     * @throws HeadlessException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   622
     *     when {@code GraphicsEnvironment.isHeadless()} returns {@code true}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   623
     * @throws SecurityException
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   624
     *     if the calling thread does not have permission to create modal dialogs
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   625
     *     with the given {@code modalityType}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * @see JComponent#getDefaultLocale
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    public JDialog(Window owner, String title, Dialog.ModalityType modalityType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                   GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        super(owner, title, modalityType, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        dialogInit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   642
     * Called by the constructors to init the {@code JDialog} properly.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    protected void dialogInit() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
        enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.WINDOW_EVENT_MASK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        setLocale( JComponent.getDefaultLocale() );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
        setRootPane(createRootPane());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
        setRootPaneCheckingEnabled(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        if (JDialog.isDefaultLookAndFeelDecorated()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            boolean supportsWindowDecorations =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
            UIManager.getLookAndFeel().getSupportsWindowDecorations();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            if (supportsWindowDecorations) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                setUndecorated(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        }
12661
6cf8b7116579 7125044: [macosx] Test failure because Component.transferFocus() works differently in applet and application.
ant
parents: 7500
diff changeset
   657
        sun.awt.SunToolkit.checkAndSetPolicy(this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     * Called by the constructor methods to create the default
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   662
     * {@code rootPane}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    protected JRootPane createRootPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        JRootPane rp = new JRootPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        // NOTE: this uses setOpaque vs LookAndFeel.installProperty as there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        // is NO reason for the RootPane not to be opaque. For painting to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        // work the contentPane must be opaque, therefor the RootPane can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        // also be opaque.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        rp.setOpaque(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        return rp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * Handles window events depending on the state of the
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   676
     * {@code defaultCloseOperation} property.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * @see #setDefaultCloseOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    protected void processWindowEvent(WindowEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        super.processWindowEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
        if (e.getID() == WindowEvent.WINDOW_CLOSING) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
            switch(defaultCloseOperation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
              case HIDE_ON_CLOSE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                 setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
                 break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
              case DISPOSE_ON_CLOSE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
                 dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                 break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
              case DO_NOTHING_ON_CLOSE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                 default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
                 break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * Sets the operation that will happen by default when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * the user initiates a "close" on this dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * You must specify one of the following choices:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * <ul>
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   705
     * <li>{@code DO_NOTHING_ON_CLOSE}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   706
     * (defined in {@code WindowConstants}):
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * Don't do anything; require the
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   708
     * program to handle the operation in the {@code windowClosing}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   709
     * method of a registered {@code WindowListener} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   711
     * <li>{@code HIDE_ON_CLOSE}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   712
     * (defined in {@code WindowConstants}):
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     * Automatically hide the dialog after
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   714
     * invoking any registered {@code WindowListener}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     * objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   717
     * <li>{@code DISPOSE_ON_CLOSE}
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   718
     * (defined in {@code WindowConstants}):
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * Automatically hide and dispose the
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   720
     * dialog after invoking any registered {@code WindowListener}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * objects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * <p>
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   724
     * The value is set to {@code HIDE_ON_CLOSE} by default. Changes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * to the value of this property cause the firing of a property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * change event, with property name "defaultCloseOperation".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * <b>Note</b>: When the last displayable window within the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     * Java virtual machine (VM) is disposed of, the VM may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * terminate.  See <a href="../../java/awt/doc-files/AWTThreadIssues.html">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     * AWT Threading Issues</a> for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     * @param operation the operation which should be performed when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     *        user closes the dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     * @throws IllegalArgumentException if defaultCloseOperation value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
     *         isn't one of the above valid values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
     * @see #addWindowListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     * @see #getDefaultCloseOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * @see WindowConstants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     *   preferred: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     *       bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     *        enum: DO_NOTHING_ON_CLOSE WindowConstants.DO_NOTHING_ON_CLOSE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     *              HIDE_ON_CLOSE       WindowConstants.HIDE_ON_CLOSE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     *              DISPOSE_ON_CLOSE    WindowConstants.DISPOSE_ON_CLOSE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     * description: The dialog's default close operation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    public void setDefaultCloseOperation(int operation) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        if (operation != DO_NOTHING_ON_CLOSE &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
            operation != HIDE_ON_CLOSE &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
            operation != DISPOSE_ON_CLOSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
            throw new IllegalArgumentException("defaultCloseOperation must be one of: DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, or DISPOSE_ON_CLOSE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
        int oldValue = this.defaultCloseOperation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        this.defaultCloseOperation = operation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        firePropertyChange("defaultCloseOperation", oldValue, operation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
    * Returns the operation which occurs when the user
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
    * initiates a "close" on this dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
    * @return an integer indicating the window-close operation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    * @see #setDefaultCloseOperation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    public int getDefaultCloseOperation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        return defaultCloseOperation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * Sets the {@code transferHandler} property, which is a mechanism to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * support transfer of data into this component. Use {@code null}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * if the component does not support data transfer operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * If the system property {@code suppressSwingDropSupport} is {@code false}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     * (the default) and the current drop target on this component is either
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * {@code null} or not a user-set drop target, this method will change the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     * drop target as follows: If {@code newHandler} is {@code null} it will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * clear the drop target. If not {@code null} it will install a new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     * {@code DropTarget}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     * Note: When used with {@code JDialog}, {@code TransferHandler} only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     * provides data import capability, as the data export related methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * are currently typed to {@code JComponent}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     * Please see
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     * <a href="http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     * How to Use Drag and Drop and Data Transfer</a>, a section in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     * <em>The Java Tutorial</em>, for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
     * @param newHandler the new {@code TransferHandler}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     * @see TransferHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     * @see #getTransferHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     * @see java.awt.Component#setDropTarget
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     *        bound: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     *       hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     *  description: Mechanism for transfer of data into the component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
    public void setTransferHandler(TransferHandler newHandler) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        TransferHandler oldHandler = transferHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        transferHandler = newHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        SwingUtilities.installSwingDropTargetAsNecessary(this, transferHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        firePropertyChange("transferHandler", oldHandler, newHandler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   813
     * Gets the {@code transferHandler} property.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   815
     * @return the value of the {@code transferHandler} property
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
     * @see TransferHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     * @see #setTransferHandler
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
    public TransferHandler getTransferHandler() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
        return transferHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   826
     * Calls {@code paint(g)}.  This method was overridden to
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     * prevent an unnecessary call to clear the background.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   829
     * @param g  the {@code Graphics} context in which to paint
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
    public void update(Graphics g) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
        paint(g);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    * Sets the menubar for this dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
    * @param menu the menubar being placed in the dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
    * @see #getJMenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
    * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    *      hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
    * description: The menubar for accessing pulldown menus from this dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
    public void setJMenuBar(JMenuBar menu) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        getRootPane().setMenuBar(menu);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
    * Returns the menubar set on this dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    * @see #setJMenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    public JMenuBar getJMenuBar() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        return getRootPane().getMenuBar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   861
     * Returns whether calls to {@code add} and
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   862
     * {@code setLayout} are forwarded to the {@code contentPane}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   864
     * @return true if {@code add} and {@code setLayout}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     *         are fowarded; false otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
     * @see #addImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     * @see #setLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    protected boolean isRootPaneCheckingEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        return rootPaneCheckingEnabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   878
     * Sets whether calls to {@code add} and
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   879
     * {@code setLayout} are forwarded to the {@code contentPane}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   881
     * @param enabled  true if {@code add} and {@code setLayout}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     *        are forwarded, false if they should operate directly on the
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   883
     *        {@code JDialog}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
     * @see #addImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     * @see #setLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
     * @see #isRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
     *      hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
     * description: Whether the add and setLayout methods are forwarded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
    protected void setRootPaneCheckingEnabled(boolean enabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
        rootPaneCheckingEnabled = enabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   898
     * Adds the specified child {@code Component}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     * This method is overridden to conditionally forward calls to the
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   900
     * {@code contentPane}.
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   901
     * By default, children are added to the {@code contentPane} instead
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
     * of the frame, refer to {@link javax.swing.RootPaneContainer} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
     * details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
     * @param comp the component to be enhanced
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
     * @param constraints the constraints to be respected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
     * @param index the index
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   908
     * @throws IllegalArgumentException if {@code index} is invalid
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   909
     * @throws IllegalArgumentException if adding the container's parent
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
     *                  to itself
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   911
     * @throws IllegalArgumentException if adding a window to a container
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
    protected void addImpl(Component comp, Object constraints, int index)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
        if(isRootPaneCheckingEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
            getContentPane().add(comp, constraints, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
            super.addImpl(comp, constraints, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
     * Removes the specified component from the container. If
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   928
     * {@code comp} is not the {@code rootPane}, this will forward
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   929
     * the call to the {@code contentPane}. This will do nothing if
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   930
     * {@code comp} is not a child of the {@code JDialog} or
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   931
     * {@code contentPane}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
     * @param comp the component to be removed
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   934
     * @throws NullPointerException if {@code comp} is null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
     * @see #add
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
    public void remove(Component comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
        if (comp == rootPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
            super.remove(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
            getContentPane().remove(comp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   948
     * Sets the {@code LayoutManager}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     * Overridden to conditionally forward the call to the
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   950
     * {@code contentPane}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     * Refer to {@link javax.swing.RootPaneContainer} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     * more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   954
     * @param manager the {@code LayoutManager}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
     * @see #setRootPaneCheckingEnabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
     * @see javax.swing.RootPaneContainer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
    public void setLayout(LayoutManager manager) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
        if(isRootPaneCheckingEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
            getContentPane().setLayout(manager);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
            super.setLayout(manager);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   969
     * Returns the {@code rootPane} object for this dialog.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
     * @see #setRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
     * @see RootPaneContainer#getRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
    public JRootPane getRootPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
        return rootPane;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   980
     * Sets the {@code rootPane} property.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * This method is called by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
   983
     * @param root the {@code rootPane} object for this dialog
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
     * @see #getRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     *   hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
     * description: the RootPane object for this dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
    protected void setRootPane(JRootPane root) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
        if(rootPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
            remove(rootPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
        rootPane = root;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
        if(rootPane != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
            boolean checkingEnabled = isRootPaneCheckingEnabled();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
                setRootPaneCheckingEnabled(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
                add(rootPane, BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
            finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
                setRootPaneCheckingEnabled(checkingEnabled);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1010
     * Returns the {@code contentPane} object for this dialog.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1012
     * @return the {@code contentPane} property
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
     * @see #setContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
     * @see RootPaneContainer#getContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
    public Container getContentPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
        return getRootPane().getContentPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
   /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1023
     * Sets the {@code contentPane} property.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     * This method is called by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
     * <p>
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1026
     * Swing's painting architecture requires an opaque {@code JComponent}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
     * in the containment hiearchy. This is typically provided by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     * content pane. If you replace the content pane it is recommended you
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1029
     * replace it with an opaque {@code JComponent}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     * @see JRootPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1032
     * @param contentPane the {@code contentPane} object for this dialog
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1034
     * @throws java.awt.IllegalComponentStateException (a runtime
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1035
     *            exception) if the content pane parameter is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
     * @see #getContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
     * @see RootPaneContainer#setContentPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
     *     hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
     *     description: The client area of the dialog where child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
     *                  components are normally inserted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
    public void setContentPane(Container contentPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
        getRootPane().setContentPane(contentPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1049
     * Returns the {@code layeredPane} object for this dialog.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1051
     * @return the {@code layeredPane} property
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
     * @see #setLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
     * @see RootPaneContainer#getLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
    public JLayeredPane getLayeredPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
        return getRootPane().getLayeredPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1061
     * Sets the {@code layeredPane} property.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
     * This method is called by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1064
     * @param layeredPane the new {@code layeredPane} property
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1066
     * @throws java.awt.IllegalComponentStateException (a runtime
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
     *            exception) if the layered pane parameter is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
     * @see #getLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
     * @see RootPaneContainer#setLayeredPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
     *     hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
     *     description: The pane which holds the various dialog layers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
    public void setLayeredPane(JLayeredPane layeredPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
        getRootPane().setLayeredPane(layeredPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1080
     * Returns the {@code glassPane} object for this dialog.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1082
     * @return the {@code glassPane} property
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
     * @see #setGlassPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
     * @see RootPaneContainer#getGlassPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
    public Component getGlassPane() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
        return getRootPane().getGlassPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1092
     * Sets the {@code glassPane} property.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
     * This method is called by the constructor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1095
     * @param glassPane the {@code glassPane} object for this dialog
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
     * @see #getGlassPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
     * @see RootPaneContainer#setGlassPane
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
     * @beaninfo
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
     *     hidden: true
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
     *     description: A transparent pane used for menu rendering.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
    public void setGlassPane(Component glassPane) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
        getRootPane().setGlassPane(glassPane);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
    public Graphics getGraphics() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
        JComponent.getGraphicsInvoked(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
        return super.getGraphics();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
     * Repaints the specified rectangle of this component within
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1119
     * {@code time} milliseconds.  Refer to {@code RepaintManager}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
     * for details on how the repaint is handled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
     * @param     time   maximum time in milliseconds before update
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
     * @param     x    the <i>x</i> coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
     * @param     y    the <i>y</i> coordinate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
     * @param     width    the width
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
     * @param     height   the height
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
     * @see       RepaintManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
     * @since     1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
    public void repaint(long time, int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
        if (RepaintManager.HANDLE_TOP_LEVEL_PAINT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
            RepaintManager.currentManager(this).addDirtyRegion(
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
                              this, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
            super.repaint(time, x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1141
     * Provides a hint as to whether or not newly created {@code JDialog}s
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
     * should have their Window decorations (such as borders, widgets to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
     * close the window, title...) provided by the current look
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1144
     * and feel. If {@code defaultLookAndFeelDecorated} is true,
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1145
     * the current {@code LookAndFeel} supports providing window
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
     * decorations, and the current window manager supports undecorated
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1147
     * windows, then newly created {@code JDialog}s will have their
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1148
     * Window decorations provided by the current {@code LookAndFeel}.
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1149
     * Otherwise, newly created {@code JDialog}s will have their
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
     * Window decorations provided by the current window manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
     * You can get the same effect on a single JDialog by doing the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
     *    JDialog dialog = new JDialog();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
     *    dialog.setUndecorated(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
     *    dialog.getRootPane().setWindowDecorationStyle(JRootPane.PLAIN_DIALOG);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
     * @param defaultLookAndFeelDecorated A hint as to whether or not current
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
     *        look and feel should provide window decorations
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
     * @see javax.swing.LookAndFeel#getSupportsWindowDecorations
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
    public static void setDefaultLookAndFeelDecorated(boolean defaultLookAndFeelDecorated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
        if (defaultLookAndFeelDecorated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
            SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
            SwingUtilities.appContextPut(defaultLookAndFeelDecoratedKey, Boolean.FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1173
     * Returns true if newly created {@code JDialog}s should have their
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
     * Window decorations provided by the current look and feel. This is only
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
     * a hint, as certain look and feels may not support this feature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
     * @return true if look and feel should provide Window decorations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
    public static boolean isDefaultLookAndFeelDecorated() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
        Boolean defaultLookAndFeelDecorated =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
            (Boolean) SwingUtilities.appContextGet(defaultLookAndFeelDecoratedKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
        if (defaultLookAndFeelDecorated == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
            defaultLookAndFeelDecorated = Boolean.FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
        return defaultLookAndFeelDecorated.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
    /**
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1190
     * Returns a string representation of this {@code JDialog}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
     * This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
     * is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
     * implementations. The returned string may be empty but may not
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1195
     * be {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
     *
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1197
     * @return  a string representation of this {@code JDialog}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
        String defaultCloseOperationString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
        if (defaultCloseOperation == HIDE_ON_CLOSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
            defaultCloseOperationString = "HIDE_ON_CLOSE";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
        } else if (defaultCloseOperation == DISPOSE_ON_CLOSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
            defaultCloseOperationString = "DISPOSE_ON_CLOSE";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
        } else if (defaultCloseOperation == DO_NOTHING_ON_CLOSE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
            defaultCloseOperationString = "DO_NOTHING_ON_CLOSE";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
        } else defaultCloseOperationString = "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
        String rootPaneString = (rootPane != null ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
                                 rootPane.toString() : "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
        String rootPaneCheckingEnabledString = (rootPaneCheckingEnabled ?
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
                                                "true" : "false");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
        return super.paramString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
        ",defaultCloseOperation=" + defaultCloseOperationString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
        ",rootPane=" + rootPaneString +
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
        ",rootPaneCheckingEnabled=" + rootPaneCheckingEnabledString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
    protected AccessibleContext accessibleContext = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
     * Gets the AccessibleContext associated with this JDialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
     * For JDialogs, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
     * AccessibleJDialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
     * A new AccessibleJDialog instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
     * @return an AccessibleJDialog that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
     *         AccessibleContext of this JDialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
            accessibleContext = new AccessibleJDialog();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
     * This class implements accessibility support for the
6511
1386b1b86562 6635395: javax.swing.JDialog constructors should specify IAE throwing if invalid owners passed
malenkov
parents: 5506
diff changeset
  1244
     * {@code JDialog} class.  It provides an implementation of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
     * Java Accessibility API appropriate to dialog user-interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
     * elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
    protected class AccessibleJDialog extends AccessibleAWTDialog {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
        // AccessibleContext methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
         * Get the accessible name of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
         * @return the localized name of the object -- can be null if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
         * object does not have a name
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
        public String getAccessibleName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
            if (accessibleName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
                return accessibleName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
                if (getTitle() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
                    return super.getAccessibleName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
                    return getTitle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
         * Get the state of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
         * @return an instance of AccessibleStateSet containing the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
         * state set of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
         * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
        public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
            AccessibleStateSet states = super.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
            if (isResizable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
                states.add(AccessibleState.RESIZABLE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
            if (getFocusOwner() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
                states.add(AccessibleState.ACTIVE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
            if (isModal()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
                states.add(AccessibleState.MODAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
            return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
    } // inner class AccessibleJDialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
}