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