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