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