jdk/src/share/classes/java/awt/Dialog.java
author yan
Thu, 26 Sep 2013 16:10:36 +0400
changeset 20172 f48935a247ec
parent 16103 c9ffd920e3f0
child 21278 ef8a3a2a72f2
permissions -rw-r--r--
8025218: [javadoc] some errors in java/awt classes Reviewed-by: yan Contributed-by: Dmitry Zinkevich <dmitry.zinkevich@oracle.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
7668
d4a77089c587 6962318: Update copyright year
ohair
parents: 7512
diff changeset
     2
 * Copyright (c) 1995, 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: 3956
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: 3956
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: 3956
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3956
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3956
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.peer.DialogPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.concurrent.atomic.AtomicLong;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.security.PrivilegedAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.awt.AppContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.awt.SunToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.awt.PeerEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.awt.util.IdentityArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.awt.util.IdentityLinkedList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import sun.security.util.SecurityConstants;
16099
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
    42
import java.security.AccessControlException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * A Dialog is a top-level window with a title and a border
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * that is typically used to take some form of input from the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * The size of the dialog includes any area designated for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * border.  The dimensions of the border area can be obtained
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * using the <code>getInsets</code> method, however, since
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * these dimensions are platform-dependent, a valid insets
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * value cannot be obtained until the dialog is made displayable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * by either calling <code>pack</code> or <code>show</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * Since the border area is included in the overall size of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * dialog, the border effectively obscures a portion of the dialog,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * constraining the area available for rendering and/or displaying
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * subcomponents to the rectangle which has an upper-left corner
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * location of <code>(insets.left, insets.top)</code>, and has a size of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * <code>width - (insets.left + insets.right)</code> by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * <code>height - (insets.top + insets.bottom)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * The default layout for a dialog is <code>BorderLayout</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * <p>
20172
f48935a247ec 8025218: [javadoc] some errors in java/awt classes
yan
parents: 16103
diff changeset
    64
 * A dialog may have its native decorations (i.e. Frame &amp; Titlebar) turned off
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * with <code>setUndecorated</code>.  This can only be done while the dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * is not {@link Component#isDisplayable() displayable}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * A dialog may have another window as its owner when it's constructed.  When
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * the owner window of a visible dialog is minimized, the dialog will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * automatically be hidden from the user. When the owner window is subsequently
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * restored, the dialog is made visible to the user again.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * In a multi-screen environment, you can create a <code>Dialog</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * on a different screen device than its owner.  See {@link java.awt.Frame} for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * A dialog can be either modeless (the default) or modal.  A modal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * dialog is one which blocks input to some other top-level windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * in the application, except for any windows created with the dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * as their owner. See <a href="doc-files/Modality.html">AWT Modality</a>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * specification for details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * Dialogs are capable of generating the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * <code>WindowEvents</code>:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * <code>WindowOpened</code>, <code>WindowClosing</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * <code>WindowClosed</code>, <code>WindowActivated</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * <code>WindowDeactivated</code>, <code>WindowGainedFocus</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * <code>WindowLostFocus</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * @see WindowEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * @see Window#addWindowListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * @author      Sami Shaio
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * @author      Arthur van Hoff
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * @since       JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
public class Dialog extends Window {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        /* ensure that the necessary native libraries are loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        Toolkit.loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        if (!GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
            initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * A dialog's resizable property. Will be true
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * if the Dialog is to be resizable, otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * it will be false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @see #setResizable(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    boolean resizable = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * This field indicates whether the dialog is undecorated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * This property can only be changed while the dialog is not displayable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * <code>undecorated</code> will be true if the dialog is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * undecorated, otherwise it will be false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * @see #setUndecorated(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * @see #isUndecorated()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * @see Component#isDisplayable()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    boolean undecorated = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
16099
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
   132
    private transient boolean initialized = false;
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
   133
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Modal dialogs block all input to some top-level windows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * Whether a particular window is blocked depends on dialog's type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * of modality; this is called the "scope of blocking". The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * <code>ModalityType</code> enum specifies modal types and their
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * associated scopes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * @see Dialog#getModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @see Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @see Toolkit#isModalityTypeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    public static enum ModalityType {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
         * <code>MODELESS</code> dialog doesn't block any top-level windows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        MODELESS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
         * A <code>DOCUMENT_MODAL</code> dialog blocks input to all top-level windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
         * from the same document except those from its own child hierarchy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
         * A document is a top-level window without an owner. It may contain child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
         * windows that, together with the top-level window are treated as a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
         * solid document. Since every top-level window must belong to some
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
         * document, its root can be found as the top-nearest window without an owner.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        DOCUMENT_MODAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
         * An <code>APPLICATION_MODAL</code> dialog blocks all top-level windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
         * from the same Java application except those from its own child hierarchy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
         * If there are several applets launched in a browser, they can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
         * treated either as separate applications or a single one. This behavior
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
         * is implementation-dependent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        APPLICATION_MODAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
         * A <code>TOOLKIT_MODAL</code> dialog blocks all top-level windows run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
         * from the same toolkit except those from its own child hierarchy. If there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
         * are several applets launched in a browser, all of them run with the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
         * toolkit; thus, a toolkit-modal dialog displayed by an applet may affect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
         * other applets and all windows of the browser instance which embeds the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
         * Java runtime environment for this toolkit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
         * Special <code>AWTPermission</code> "toolkitModality" must be granted to use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
         * toolkit-modal dialogs. If a <code>TOOLKIT_MODAL</code> dialog is being created
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
         * and this permission is not granted, a <code>SecurityException</code> will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
         * thrown, and no dialog will be created. If a modality type is being changed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
         * to <code>TOOLKIT_MODAL</code> and this permission is not granted, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
         * <code>SecurityException</code> will be thrown, and the modality type will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
         * be left unchanged.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        TOOLKIT_MODAL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * Default modality type for modal dialogs. The default modality type is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * <code>APPLICATION_MODAL</code>. Calling the oldstyle <code>setModal(true)</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * is equal to <code>setModalityType(DEFAULT_MODALITY_TYPE)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public final static ModalityType DEFAULT_MODALITY_TYPE = ModalityType.APPLICATION_MODAL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * True if this dialog is modal, false is the dialog is modeless.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * A modal dialog blocks user input to some application top-level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * windows. This field is kept only for backwards compatibility. Use the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * {@link Dialog.ModalityType ModalityType} enum instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @see #isModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * @see #setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @see #getModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * @see #setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * @see ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @see ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * @see #DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    boolean modal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * Modality type of this dialog. If the dialog's modality type is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * {@link Dialog.ModalityType#MODELESS ModalityType.MODELESS}, it blocks all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * user input to some application top-level windows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * @see ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * @see #getModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * @see #setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    ModalityType modalityType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * Any top-level window can be marked not to be blocked by modal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * dialogs. This is called "modal exclusion". This enum specifies
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * the possible modal exclusion types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * @see Window#getModalExclusionType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * @see Window#setModalExclusionType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * @see Toolkit#isModalExclusionTypeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    public static enum ModalExclusionType {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
         * No modal exclusion.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        NO_EXCLUDE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
         * <code>APPLICATION_EXCLUDE</code> indicates that a top-level window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
         * won't be blocked by any application-modal dialogs. Also, it isn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
         * blocked by document-modal dialogs from outside of its child hierarchy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        APPLICATION_EXCLUDE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
         * <code>TOOLKIT_EXCLUDE</code> indicates that a top-level window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
         * won't be blocked by  application-modal or toolkit-modal dialogs. Also,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
         * it isn't blocked by document-modal dialogs from outside of its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
         * child hierarchy.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
         * The "toolkitModality" <code>AWTPermission</code> must be granted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
         * for this exclusion. If an exclusion property is being changed to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
         * <code>TOOLKIT_EXCLUDE</code> and this permission is not granted, a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
         * <code>SecurityEcxeption</code> will be thrown, and the exclusion
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
         * property will be left unchanged.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        TOOLKIT_EXCLUDE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    /* operations with this list should be synchronized on tree lock*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    transient static IdentityArrayList<Dialog> modalDialogs = new IdentityArrayList<Dialog>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    transient IdentityArrayList<Window> blockedWindows = new IdentityArrayList<Window>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * Specifies the title of the Dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * This field can be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * @see #getTitle()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @see #setTitle(String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    String title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    private transient ModalEventFilter modalFilter;
6484
f5dbd940a640 6949936: Provide API for running nested events loops, similar to what modal dialogs do
art
parents: 5506
diff changeset
   284
    private transient volatile SecondaryLoop secondaryLoop;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * Indicates that this dialog is being hidden. This flag is set to true at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * the beginning of hide() and to false at the end of hide().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * @see #hide()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @see #hideAndDisposePreHandler()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * @see #hideAndDisposeHandler()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @see #shouldBlock()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    transient volatile boolean isInHide = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * Indicates that this dialog is being disposed. This flag is set to true at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * the beginning of doDispose() and to false at the end of doDispose().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * @see #hide()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * @see #hideAndDisposePreHandler()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @see #hideAndDisposeHandler()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * @see #doDispose()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    transient volatile boolean isInDispose = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    private static final String base = "dialog";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    private static int nameCounter = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    private static final long serialVersionUID = 5920926903803293709L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * Constructs an initially invisible, modeless <code>Dialog</code> with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * the specified owner <code>Frame</code> and an empty title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * @param owner the owner of the dialog or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     *     this dialog has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     *    <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     *    <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @see Component#setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * @see Component#setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     public Dialog(Frame owner) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
         this(owner, "", false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * Constructs an initially invisible <code>Dialog</code> with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * owner <code>Frame</code> and modality and an empty title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * @param owner the owner of the dialog or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     *     this dialog has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * @param modal specifes whether dialog blocks user input to other top-level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     *     windows when shown. If <code>false</code>, the dialog is <code>MODELESS</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     *     if <code>true</code>, the modality type property is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     *     <code>DEFAULT_MODALITY_TYPE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *    <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * @see java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     public Dialog(Frame owner, boolean modal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
         this(owner, "", modal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * Constructs an initially invisible, modeless <code>Dialog</code> with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * the specified owner <code>Frame</code> and title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * @param owner the owner of the dialog or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     *     this dialog has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * @param title the title of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     *     has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * @exception IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     *     <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * @see Component#setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * @see Component#setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     public Dialog(Frame owner, String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
         this(owner, title, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * Constructs an initially invisible <code>Dialog</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * specified owner <code>Frame</code>, title and modality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * @param owner the owner of the dialog or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     *     this dialog has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * @param title the title of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     *     has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * @param modal specifes whether dialog blocks user input to other top-level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     *     windows when shown. If <code>false</code>, the dialog is <code>MODELESS</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     *     if <code>true</code>, the modality type property is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     *     <code>DEFAULT_MODALITY_TYPE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     *    <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     *    <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * @see java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * @see Component#setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * @see Component#setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     public Dialog(Frame owner, String title, boolean modal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
         this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * Constructs an initially invisible <code>Dialog</code> with the specified owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * <code>Frame</code>, title, modality, and <code>GraphicsConfiguration</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @param owner the owner of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     *     has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * @param title the title of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     *     has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * @param modal specifes whether dialog blocks user input to other top-level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     *     windows when shown. If <code>false</code>, the dialog is <code>MODELESS</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     *     if <code>true</code>, the modality type property is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     *     <code>DEFAULT_MODALITY_TYPE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * @param gc the <code>GraphicsConfiguration</code> of the target screen device;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     *     if <code>null</code>, the default system <code>GraphicsConfiguration</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     *     is assumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * @exception java.lang.IllegalArgumentException if <code>gc</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     *     is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * @see java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * @see Component#setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * @see Component#setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     public Dialog(Frame owner, String title, boolean modal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                   GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
         this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * Constructs an initially invisible, modeless <code>Dialog</code> with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * the specified owner <code>Dialog</code> and an empty title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * @param owner the owner of the dialog or <code>null</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     *     dialog has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     *     <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     public Dialog(Dialog owner) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
         this(owner, "", false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * Constructs an initially invisible, modeless <code>Dialog</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * with the specified owner <code>Dialog</code> and title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * @param owner the owner of the dialog or <code>null</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     *     has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * @param title the title of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     *     has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     *     <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     public Dialog(Dialog owner, String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
         this(owner, title, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * Constructs an initially invisible <code>Dialog</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * specified owner <code>Dialog</code>, title, and modality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * @param owner the owner of the dialog or <code>null</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     *     dialog has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * @param title the title of the dialog or <code>null</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     *     dialog has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * @param modal specifes whether dialog blocks user input to other top-level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     *     windows when shown. If <code>false</code>, the dialog is <code>MODELESS</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     *     if <code>true</code>, the modality type property is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     *     <code>DEFAULT_MODALITY_TYPE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * @exception IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     *    <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     *    <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * @see java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     public Dialog(Dialog owner, String title, boolean modal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
         this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * Constructs an initially invisible <code>Dialog</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * specified owner <code>Dialog</code>, title, modality and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * <code>GraphicsConfiguration</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * @param owner the owner of the dialog or <code>null</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     *     dialog has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     * @param title the title of the dialog or <code>null</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     *     dialog has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * @param modal specifes whether dialog blocks user input to other top-level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     *     windows when shown. If <code>false</code>, the dialog is <code>MODELESS</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     *     if <code>true</code>, the modality type property is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     *     <code>DEFAULT_MODALITY_TYPE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * @param gc the <code>GraphicsConfiguration</code> of the target screen device;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     *     if <code>null</code>, the default system <code>GraphicsConfiguration</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     *     is assumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * @exception java.lang.IllegalArgumentException if <code>gc</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     *    is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     *    <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * @see java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * @see Component#setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * @see Component#setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     public Dialog(Dialog owner, String title, boolean modal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
                   GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
         this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * Constructs an initially invisible, modeless <code>Dialog</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * specified owner <code>Window</code> and an empty title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * @param owner the owner of the dialog. The owner must be an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     *     {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     *     of their descendents or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     *     is not an instance of {@link java.awt.Dialog Dialog} or {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     *     java.awt.Frame Frame}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     *     <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    public Dialog(Window owner) {
7500
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 6636
diff changeset
   571
        this(owner, "", ModalityType.MODELESS);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * Constructs an initially invisible, modeless <code>Dialog</code> with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * the specified owner <code>Window</code> and title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     * @param owner the owner of the dialog. The owner must be an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     *    {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     *    of their descendents or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * @param title the title of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     *    has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     *    is not an instance of {@link java.awt.Dialog Dialog} or {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     *    java.awt.Frame Frame}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     *    <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     *    <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    public Dialog(Window owner, String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
        this(owner, title, ModalityType.MODELESS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * Constructs an initially invisible <code>Dialog</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * specified owner <code>Window</code> and modality and an empty title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * @param owner the owner of the dialog. The owner must be an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     *    {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     *    of their descendents or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * @param modalityType specifies whether dialog blocks input to other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     *    windows when shown. <code>null</code> value and unsupported modality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     *    types are equivalent to <code>MODELESS</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     *    is not an instance of {@link java.awt.Dialog Dialog} or {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     *    java.awt.Frame Frame}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     *    <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     *    <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     * @exception SecurityException if the calling thread does not have permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     *    to create modal dialogs with the given <code>modalityType</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * @see java.awt.Toolkit#isModalityTypeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    public Dialog(Window owner, ModalityType modalityType) {
7500
dec4b445efc6 6639507: Title of javax.swing.JDialog is null while spec says it's empty
rupashka
parents: 6636
diff changeset
   630
        this(owner, "", modalityType);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * Constructs an initially invisible <code>Dialog</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * specified owner <code>Window</code>, title and modality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     * @param owner the owner of the dialog. The owner must be an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     *     {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     *     of their descendents or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * @param title the title of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     *     has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     * @param modalityType specifies whether dialog blocks input to other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     *    windows when shown. <code>null</code> value and unsupported modality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     *    types are equivalent to <code>MODELESS</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     *     is not an instance of {@link java.awt.Dialog Dialog} or {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     *     java.awt.Frame Frame}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     *     <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     * @exception SecurityException if the calling thread does not have permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     *     to create modal dialogs with the given <code>modalityType</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     * @see java.awt.Toolkit#isModalityTypeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    public Dialog(Window owner, String title, ModalityType modalityType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        super(owner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        if ((owner != null) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
            !(owner instanceof Frame) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
            !(owner instanceof Dialog))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
            throw new IllegalArgumentException("Wrong parent window");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        this.title = title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        setModalityType(modalityType);
12661
6cf8b7116579 7125044: [macosx] Test failure because Component.transferFocus() works differently in applet and application.
ant
parents: 12645
diff changeset
   676
        SunToolkit.checkAndSetPolicy(this);
16099
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
   677
        initialized = true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * Constructs an initially invisible <code>Dialog</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * specified owner <code>Window</code>, title, modality and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * <code>GraphicsConfiguration</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * @param owner the owner of the dialog. The owner must be an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     *     {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     *     of their descendents or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * @param title the title of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     *     has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * @param modalityType specifies whether dialog blocks input to other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     *    windows when shown. <code>null</code> value and unsupported modality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     *    types are equivalent to <code>MODELESS</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     * @param gc the <code>GraphicsConfiguration</code> of the target screen device;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     *     if <code>null</code>, the default system <code>GraphicsConfiguration</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     *     is assumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     *     is not an instance of {@link java.awt.Dialog Dialog} or {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     *     java.awt.Frame Frame}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * @exception java.lang.IllegalArgumentException if <code>gc</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     *     is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * @exception SecurityException if the calling thread does not have permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     *     to create modal dialogs with the given <code>modalityType</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * @see java.awt.Toolkit#isModalityTypeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    public Dialog(Window owner, String title, ModalityType modalityType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
                  GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        super(owner, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
        if ((owner != null) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
            !(owner instanceof Frame) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
            !(owner instanceof Dialog))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
            throw new IllegalArgumentException("wrong owner window");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        this.title = title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
        setModalityType(modalityType);
12661
6cf8b7116579 7125044: [macosx] Test failure because Component.transferFocus() works differently in applet and application.
ant
parents: 12645
diff changeset
   728
        SunToolkit.checkAndSetPolicy(this);
16099
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
   729
        initialized = true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     * Construct a name for this component.  Called by getName() when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     * name is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    String constructComponentName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        synchronized (Dialog.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
            return base + nameCounter++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     * Makes this Dialog displayable by connecting it to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * a native screen resource.  Making a dialog displayable will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * cause any of its children to be made displayable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     * This method is called internally by the toolkit and should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     * not be called directly by programs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     * @see Component#isDisplayable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     * @see #removeNotify
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
    public void addNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
            if (parent != null && parent.getPeer() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
                parent.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
            if (peer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
                peer = getToolkit().createDialog(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
            super.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * Indicates whether the dialog is modal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * This method is obsolete and is kept for backwards compatiblity only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     * Use {@link #getModalityType getModalityType()} instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * @return    <code>true</code> if this dialog window is modal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     *            <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * @see       java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * @see       java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * @see       java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * @see       java.awt.Dialog#getModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * @see       java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
    public boolean isModal() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        return isModal_NoClientCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
    final boolean isModal_NoClientCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
        return modalityType != ModalityType.MODELESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     * Specifies whether this dialog should be modal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     * This method is obsolete and is kept for backwards compatibility only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     * Use {@link #setModalityType setModalityType()} instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     * Note: changing modality of the visible dialog may have no effect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
     * until it is hidden and then shown again.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     * @param modal specifies whether dialog blocks input to other windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     *     when shown; calling to <code>setModal(true)</code> is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     *     <code>setModalityType(Dialog.DEFAULT_MODALITY_TYPE)</code>, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     *     calling to <code>setModal(false)</code> is equvivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     *     <code>setModalityType(Dialog.ModalityType.MODELESS)</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     * @see       java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     * @see       java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     * @see       java.awt.Dialog#isModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     * @see       java.awt.Dialog#getModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * @see       java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     * @since     1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
    public void setModal(boolean modal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
        this.modal = modal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        setModalityType(modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
     * Returns the modality type of this dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
     * @return modality type of this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    public ModalityType getModalityType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
        return modalityType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     * Sets the modality type for this dialog. See {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * java.awt.Dialog.ModalityType ModalityType} for possible modality types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * If the given modality type is not supported, <code>MODELESS</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * is used. You may want to call <code>getModalityType()</code> after calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * this method to ensure that the modality type has been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     * Note: changing modality of the visible dialog may have no effect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
     * until it is hidden and then shown again.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * @param type specifies whether dialog blocks input to other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     *     windows when shown. <code>null</code> value and unsupported modality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     *     types are equivalent to <code>MODELESS</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     * @exception SecurityException if the calling thread does not have permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     *     to create modal dialogs with the given <code>modalityType</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     * @see       java.awt.Dialog#getModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     * @see       java.awt.Toolkit#isModalityTypeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
     * @since     1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
    public void setModalityType(ModalityType type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        if (type == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
            type = Dialog.ModalityType.MODELESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        if (!Toolkit.getDefaultToolkit().isModalityTypeSupported(type)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
            type = Dialog.ModalityType.MODELESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        if (modalityType == type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
        }
16099
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
   859
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
   860
        checkModalityPermission(type);
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
   861
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        modalityType = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        modal = (modalityType != ModalityType.MODELESS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
     * Gets the title of the dialog. The title is displayed in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     * dialog's border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
     * @return    the title of this dialog window. The title may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     *            <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
     * @see       java.awt.Dialog#setTitle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    public String getTitle() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        return title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
     * Sets the title of the Dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
     * @param title the title displayed in the dialog's border;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
         * a null value results in an empty title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
     * @see #getTitle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    public void setTitle(String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        String oldTitle = this.title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
            this.title = title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
            DialogPeer peer = (DialogPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
                peer.setTitle(title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        firePropertyChange("title", oldTitle, title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
     * @return true if we actually showed, false if we just called toFront()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
    private boolean conditionalShow(Component toFocus, AtomicLong time) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
        boolean retval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        closeSplashScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
            if (peer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
            }
9202
164591974d77 7027013: Regression: JComponent.revalidate() has no effect on invisible components
anthony
parents: 7668
diff changeset
   908
            validateUnconditionally();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
            if (visible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
                toFront();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                retval = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                visible = retval = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                // check if this dialog should be modal blocked BEFORE calling peer.show(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                // otherwise, a pair of FOCUS_GAINED and FOCUS_LOST may be mistakenly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                // generated for the dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
                if (!isModal()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
                    checkShouldBeBlocked(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
                    modalDialogs.add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                    modalShow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
                if (toFocus != null && time != null && isFocusable() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
                    isEnabled() && !isModalBlocked()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                    // keep the KeyEvents from being dispatched
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
                    // until the focus has been transfered
13652
42544e68dc39 6981400: Tabbing between textfield do not work properly when ALT+TAB
ant
parents: 12661
diff changeset
   929
                    time.set(Toolkit.getEventQueue().getMostRecentKeyEventTime());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
                    KeyboardFocusManager.getCurrentKeyboardFocusManager().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
                        enqueueKeyEvents(time.get(), toFocus);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
                // This call is required as the show() method of the Dialog class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                // does not invoke the super.show(). So wried... :(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
                mixOnShowing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
1964
934568dfe859 6749920: Cleanup AWT peer interfaces
rkennke
parents: 1183
diff changeset
   938
                peer.setVisible(true); // now guaranteed never to block
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
                if (isModalBlocked()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
                    modalBlocker.toFront();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                setLocationByPlatform(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                for (int i = 0; i < ownedWindowList.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                    Window child = ownedWindowList.elementAt(i).get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                    if ((child != null) && child.showWithParent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
                        child.show();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
                        child.showWithParent = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
                    }       // endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
                }   // endfor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
                Window.updateChildFocusableWindowState(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
                createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                                      this, parent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
                                      HierarchyEvent.SHOWING_CHANGED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
                                      Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
                if (componentListener != null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
                        (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
                        Toolkit.enabledOnToolkit(AWTEvent.COMPONENT_EVENT_MASK)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
                    ComponentEvent e =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
                        new ComponentEvent(this, ComponentEvent.COMPONENT_SHOWN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
                    Toolkit.getEventQueue().postEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
        if (retval && (state & OPENED) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
            postWindowEvent(WindowEvent.WINDOW_OPENED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
            state |= OPENED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        return retval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
     * Shows or hides this {@code Dialog} depending on the value of parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
     * {@code b}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
     * @param b if {@code true}, makes the {@code Dialog} visible,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
     * otherwise hides the {@code Dialog}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
     * If the dialog and/or its owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * are not yet displayable, both are made displayable.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     * dialog will be validated prior to being made visible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
     * If {@code false}, hides the {@code Dialog} and then causes {@code setVisible(true)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
     * to return if it is currently blocked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
     * <b>Notes for modal dialogs</b>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     * <li>{@code setVisible(true)}:  If the dialog is not already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
     * visible, this call will not return until the dialog is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
     * hidden by calling {@code setVisible(false)} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
     * {@code dispose}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
     * <li>{@code setVisible(false)}:  Hides the dialog and then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
     * returns on {@code setVisible(true)} if it is currently blocked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
     * <li>It is OK to call this method from the event dispatching
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
     * thread because the toolkit ensures that other events are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
     * not blocked while this method is blocked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     * @see java.awt.Window#setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     * @see java.awt.Window#dispose
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     * @see java.awt.Component#isDisplayable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     * @see java.awt.Component#validate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     * @see java.awt.Dialog#isModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
    public void setVisible(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
        super.setVisible(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
     * Makes the {@code Dialog} visible. If the dialog and/or its owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
     * are not yet displayable, both are made displayable.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
     * dialog will be validated prior to being made visible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
     * If the dialog is already visible, this will bring the dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
     * to the front.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
     * If the dialog is modal and is not already visible, this call
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
     * will not return until the dialog is hidden by calling hide or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
     * dispose. It is permissible to show modal dialogs from the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
     * dispatching thread because the toolkit will ensure that another
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
     * event pump runs while the one which invoked this method is blocked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
     * @see Component#hide
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
     * @see Component#isDisplayable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
     * @see Component#validate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     * @see #isModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     * @see Window#setVisible(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
     * @deprecated As of JDK version 1.5, replaced by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
     * {@link #setVisible(boolean) setVisible(boolean)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
    public void show() {
16099
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1030
        if (!initialized) {
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1031
            throw new IllegalStateException("The dialog component " +
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1032
                "has not been initialized properly");
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1033
        }
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1034
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
        beforeFirstShow = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
        if (!isModal()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
            conditionalShow(null, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
        } else {
6484
f5dbd940a640 6949936: Provide API for running nested events loops, similar to what modal dialogs do
art
parents: 5506
diff changeset
  1039
            AppContext showAppContext = AppContext.getAppContext();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
            AtomicLong time = new AtomicLong();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
            Component predictedFocusOwner = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
                predictedFocusOwner = getMostRecentFocusOwner();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
                if (conditionalShow(predictedFocusOwner, time)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
                    modalFilter = ModalEventFilter.createFilterForDialog(this);
12645
e0d32945f6ab 7080109: Dialog.show() lacks doPrivileged() to access system event queue
serb
parents: 9202
diff changeset
  1047
                    final Conditional cond = new Conditional() {
6484
f5dbd940a640 6949936: Provide API for running nested events loops, similar to what modal dialogs do
art
parents: 5506
diff changeset
  1048
                        @Override
f5dbd940a640 6949936: Provide API for running nested events loops, similar to what modal dialogs do
art
parents: 5506
diff changeset
  1049
                        public boolean evaluate() {
f5dbd940a640 6949936: Provide API for running nested events loops, similar to what modal dialogs do
art
parents: 5506
diff changeset
  1050
                            return windowClosingException == null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
                    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
                    // if this dialog is toolkit-modal, the filter should be added
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
                    // to all EDTs (for all AppContexts)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
                    if (modalityType == ModalityType.TOOLKIT_MODAL) {
15318
607db339afcc 8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents: 13652
diff changeset
  1057
                        Iterator<AppContext> it = AppContext.getAppContexts().iterator();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
                        while (it.hasNext()) {
15318
607db339afcc 8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents: 13652
diff changeset
  1059
                            AppContext appContext = it.next();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
                            if (appContext == showAppContext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
                                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
                            EventQueue eventQueue = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
                            // it may occur that EDT for appContext hasn't been started yet, so
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
                            // we post an empty invocation event to trigger EDT initialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
                            Runnable createEDT = new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
                                public void run() {};
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
                            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
                            eventQueue.postEvent(new InvocationEvent(this, createEDT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
                            EventDispatchThread edt = eventQueue.getDispatchThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
                            edt.addEventFilter(modalFilter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
                    modalityPushed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
                    try {
12645
e0d32945f6ab 7080109: Dialog.show() lacks doPrivileged() to access system event queue
serb
parents: 9202
diff changeset
  1077
                        final EventQueue eventQueue = AccessController.doPrivileged(
e0d32945f6ab 7080109: Dialog.show() lacks doPrivileged() to access system event queue
serb
parents: 9202
diff changeset
  1078
                            new PrivilegedAction<EventQueue>() {
e0d32945f6ab 7080109: Dialog.show() lacks doPrivileged() to access system event queue
serb
parents: 9202
diff changeset
  1079
                                public EventQueue run() {
e0d32945f6ab 7080109: Dialog.show() lacks doPrivileged() to access system event queue
serb
parents: 9202
diff changeset
  1080
                                    return Toolkit.getDefaultToolkit().getSystemEventQueue();
e0d32945f6ab 7080109: Dialog.show() lacks doPrivileged() to access system event queue
serb
parents: 9202
diff changeset
  1081
                                }
e0d32945f6ab 7080109: Dialog.show() lacks doPrivileged() to access system event queue
serb
parents: 9202
diff changeset
  1082
                        });
6636
a636784de382 6987896: Modal dialogs resumes the calling thread before it's hidden
art
parents: 6484
diff changeset
  1083
                        secondaryLoop = eventQueue.createSecondaryLoop(cond, modalFilter, 0);
6484
f5dbd940a640 6949936: Provide API for running nested events loops, similar to what modal dialogs do
art
parents: 5506
diff changeset
  1084
                        if (!secondaryLoop.enter()) {
f5dbd940a640 6949936: Provide API for running nested events loops, similar to what modal dialogs do
art
parents: 5506
diff changeset
  1085
                            secondaryLoop = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
                    } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
                        modalityPopped();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
                    // if this dialog is toolkit-modal, its filter must be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
                    // from all EDTs (for all AppContexts)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
                    if (modalityType == ModalityType.TOOLKIT_MODAL) {
15318
607db339afcc 8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents: 13652
diff changeset
  1094
                        Iterator<AppContext> it = AppContext.getAppContexts().iterator();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
                        while (it.hasNext()) {
15318
607db339afcc 8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents: 13652
diff changeset
  1096
                            AppContext appContext = it.next();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
                            if (appContext == showAppContext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
                                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
                            EventQueue eventQueue = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
                            EventDispatchThread edt = eventQueue.getDispatchThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
                            edt.removeEventFilter(modalFilter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
                    if (windowClosingException != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
                        windowClosingException.fillInStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
                        throw windowClosingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
                if (predictedFocusOwner != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
                    // Restore normal key event dispatching
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
                    KeyboardFocusManager.getCurrentKeyboardFocusManager().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
                        dequeueKeyEvents(time.get(), predictedFocusOwner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
    final void modalityPushed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
        Toolkit tk = Toolkit.getDefaultToolkit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
        if (tk instanceof SunToolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
            SunToolkit stk = (SunToolkit)tk;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
            stk.notifyModalityPushed(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
    final void modalityPopped() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
        Toolkit tk = Toolkit.getDefaultToolkit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
        if (tk instanceof SunToolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
            SunToolkit stk = (SunToolkit)tk;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
            stk.notifyModalityPopped(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
    void interruptBlocking() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
        if (isModal()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
            disposeImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
        } else if (windowClosingException != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
            windowClosingException.fillInStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
            windowClosingException.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
            windowClosingException = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
    }
6484
f5dbd940a640 6949936: Provide API for running nested events loops, similar to what modal dialogs do
art
parents: 5506
diff changeset
  1146
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
    private void hideAndDisposePreHandler() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
        isInHide = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
        synchronized (getTreeLock()) {
6484
f5dbd940a640 6949936: Provide API for running nested events loops, similar to what modal dialogs do
art
parents: 5506
diff changeset
  1150
            if (secondaryLoop != null) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
                modalHide();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
                // dialog can be shown and then disposed before its
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
                // modal filter is created
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
                if (modalFilter != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
                    modalFilter.disable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
                modalDialogs.remove(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
    private void hideAndDisposeHandler() {
6484
f5dbd940a640 6949936: Provide API for running nested events loops, similar to what modal dialogs do
art
parents: 5506
diff changeset
  1162
        if (secondaryLoop != null) {
f5dbd940a640 6949936: Provide API for running nested events loops, similar to what modal dialogs do
art
parents: 5506
diff changeset
  1163
            secondaryLoop.exit();
f5dbd940a640 6949936: Provide API for running nested events loops, similar to what modal dialogs do
art
parents: 5506
diff changeset
  1164
            secondaryLoop = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
        isInHide = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
     * Hides the Dialog and then causes {@code show} to return if it is currently
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
     * blocked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
     * @see Window#show
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
     * @see Window#dispose
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
     * @see Window#setVisible(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
     * @deprecated As of JDK version 1.5, replaced by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
     * {@link #setVisible(boolean) setVisible(boolean)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
    public void hide() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
        hideAndDisposePreHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
        super.hide();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
        // fix for 5048370: if hide() is called from super.doDispose(), then
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
        // hideAndDisposeHandler() should not be called here as it will be called
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
        // at the end of doDispose()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
        if (!isInDispose) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
            hideAndDisposeHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
     * Disposes the Dialog and then causes show() to return if it is currently
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
     * blocked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
    void doDispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
        // fix for 5048370: set isInDispose flag to true to prevent calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
        // to hideAndDisposeHandler() from hide()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
        isInDispose = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
        super.doDispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
        hideAndDisposeHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
        isInDispose = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
     * If this dialog is modal and blocks some windows, then all of them are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
     * also sent to the back to keep them below the blocking dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
     * @see java.awt.Window#toBack
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
    public void toBack() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
        super.toBack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
        if (visible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
            synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
                for (Window w : blockedWindows) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
                    w.toBack_NoClientCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
     * Indicates whether this dialog is resizable by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
     * By default, all dialogs are initially resizable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
     * @return    <code>true</code> if the user can resize the dialog;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
     *            <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
     * @see       java.awt.Dialog#setResizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
    public boolean isResizable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
        return resizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
     * Sets whether this dialog is resizable by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
     * @param     resizable <code>true</code> if the user can
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
     *                 resize this dialog; <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
     * @see       java.awt.Dialog#isResizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
    public void setResizable(boolean resizable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
        boolean testvalid = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
            this.resizable = resizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
            DialogPeer peer = (DialogPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
                peer.setResizable(resizable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
                testvalid = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
        // On some platforms, changing the resizable state affects
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
        // the insets of the Dialog. If we could, we'd call invalidate()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
        // from the peer, but we need to guarantee that we're not holding
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
        // the Dialog lock when we call invalidate().
1183
80d6aafba03a 6682046: Mixing code does not always recalculate shapes correctly when resizing components
anthony
parents: 2
diff changeset
  1255
        if (testvalid) {
80d6aafba03a 6682046: Mixing code does not always recalculate shapes correctly when resizing components
anthony
parents: 2
diff changeset
  1256
            invalidateIfValid();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
     * Disables or enables decorations for this dialog.
7236
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1263
     * <p>
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1264
     * This method can only be called while the dialog is not displayable. To
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1265
     * make this dialog decorated, it must be opaque and have the default shape,
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1266
     * otherwise the {@code IllegalComponentStateException} will be thrown.
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1267
     * Refer to {@link Window#setShape}, {@link Window#setOpacity} and {@link
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1268
     * Window#setBackground} for details
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1269
     *
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1270
     * @param  undecorated {@code true} if no dialog decorations are to be
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1271
     *         enabled; {@code false} if dialog decorations are to be enabled
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1272
     *
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1273
     * @throws IllegalComponentStateException if the dialog is displayable
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1274
     * @throws IllegalComponentStateException if {@code undecorated} is
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1275
     *      {@code false}, and this dialog does not have the default shape
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1276
     * @throws IllegalComponentStateException if {@code undecorated} is
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1277
     *      {@code false}, and this dialog opacity is less than {@code 1.0f}
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1278
     * @throws IllegalComponentStateException if {@code undecorated} is
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1279
     *      {@code false}, and the alpha value of this dialog background
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1280
     *      color is less than {@code 1.0f}
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1281
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
     * @see    #isUndecorated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
     * @see    Component#isDisplayable
7236
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1284
     * @see    Window#getShape
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1285
     * @see    Window#getOpacity
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1286
     * @see    Window#getBackground
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1287
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
    public void setUndecorated(boolean undecorated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
        /* Make sure we don't run in the middle of peer creation.*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
            if (isDisplayable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
                throw new IllegalComponentStateException("The dialog is displayable.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
            }
7236
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1296
            if (!undecorated) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1297
                if (getOpacity() < 1.0f) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1298
                    throw new IllegalComponentStateException("The dialog is not opaque");
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1299
                }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1300
                if (getShape() != null) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1301
                    throw new IllegalComponentStateException("The dialog does not have a default shape");
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1302
                }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1303
                Color bg = getBackground();
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1304
                if ((bg != null) && (bg.getAlpha() < 255)) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1305
                    throw new IllegalComponentStateException("The dialog background color is not opaque");
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1306
                }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1307
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
            this.undecorated = undecorated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
     * Indicates whether this dialog is undecorated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
     * By default, all dialogs are initially decorated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
     * @return    <code>true</code> if dialog is undecorated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
     *                        <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
     * @see       java.awt.Dialog#setUndecorated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
    public boolean isUndecorated() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
        return undecorated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
    /**
7236
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1325
     * {@inheritDoc}
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1326
     */
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1327
    @Override
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1328
    public void setOpacity(float opacity) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1329
        synchronized (getTreeLock()) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1330
            if ((opacity < 1.0f) && !isUndecorated()) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1331
                throw new IllegalComponentStateException("The dialog is decorated");
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1332
            }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1333
            super.setOpacity(opacity);
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1334
        }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1335
    }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1336
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1337
    /**
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1338
     * {@inheritDoc}
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1339
     */
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1340
    @Override
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1341
    public void setShape(Shape shape) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1342
        synchronized (getTreeLock()) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1343
            if ((shape != null) && !isUndecorated()) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1344
                throw new IllegalComponentStateException("The dialog is decorated");
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1345
            }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1346
            super.setShape(shape);
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1347
        }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1348
    }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1349
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1350
    /**
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1351
     * {@inheritDoc}
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1352
     */
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1353
    @Override
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1354
    public void setBackground(Color bgColor) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1355
        synchronized (getTreeLock()) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1356
            if ((bgColor != null) && (bgColor.getAlpha() < 255) && !isUndecorated()) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1357
                throw new IllegalComponentStateException("The dialog is decorated");
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1358
            }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1359
            super.setBackground(bgColor);
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1360
        }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1361
    }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1362
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 6636
diff changeset
  1363
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
     * Returns a string representing the state of this dialog. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
     * method is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
     * implementations. The returned string may be empty but may not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
     * @return    the parameter string of this dialog window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
        String str = super.paramString() + "," + modalityType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
        if (title != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
            str += ",title=" + title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
        return str;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
     * Initialize JNI field and method IDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
     * --- Modality support ---
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
     * This method is called only for modal dialogs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
     * Goes through the list of all visible top-level windows and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
     * divide them into three distinct groups: blockers of this dialog,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
     * blocked by this dialog and all others. Then blocks this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
     * by first met dialog from the first group (if any) and blocks all
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
     * the windows from the second group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
    void modalShow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
        // find all the dialogs that block this one
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
        IdentityArrayList<Dialog> blockers = new IdentityArrayList<Dialog>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
        for (Dialog d : modalDialogs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
            if (d.shouldBlock(this)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
                Window w = d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
                while ((w != null) && (w != this)) {
15318
607db339afcc 8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents: 13652
diff changeset
  1406
                    w = w.getOwner_NoClientCode();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
                if ((w == this) || !shouldBlock(d) || (modalityType.compareTo(d.getModalityType()) < 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
                    blockers.add(d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
        // add all blockers' blockers to blockers :)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
        for (int i = 0; i < blockers.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
            Dialog blocker = blockers.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
            if (blocker.isModalBlocked()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
                Dialog blockerBlocker = blocker.getModalBlocker();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
                if (!blockers.contains(blockerBlocker)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
                    blockers.add(i + 1, blockerBlocker);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
        if (blockers.size() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
            blockers.get(0).blockWindow(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
        // find all windows from blockers' hierarchies
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
        IdentityArrayList<Window> blockersHierarchies = new IdentityArrayList<Window>(blockers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
        int k = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
        while (k < blockersHierarchies.size()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
            Window w = blockersHierarchies.get(k);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
            Window[] ownedWindows = w.getOwnedWindows_NoClientCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
            for (Window win : ownedWindows) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
                blockersHierarchies.add(win);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
            k++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
        java.util.List<Window> toBlock = new IdentityLinkedList<Window>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
        // block all windows from scope of blocking except from blockers' hierarchies
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
        IdentityArrayList<Window> unblockedWindows = Window.getAllUnblockedWindows();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
        for (Window w : unblockedWindows) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
            if (shouldBlock(w) && !blockersHierarchies.contains(w)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
                if ((w instanceof Dialog) && ((Dialog)w).isModal_NoClientCode()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
                    Dialog wd = (Dialog)w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
                    if (wd.shouldBlock(this) && (modalDialogs.indexOf(wd) > modalDialogs.indexOf(this))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
                toBlock.add(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
        blockWindows(toBlock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
        if (!isModalBlocked()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
            updateChildrenBlocking();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
     * This method is called only for modal dialogs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
     * Unblocks all the windows blocked by this modal dialog. After
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
     * each of them has been unblocked, it is checked to be blocked by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
     * any other modal dialogs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
    void modalHide() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
        // we should unblock all the windows first...
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
        IdentityArrayList<Window> save = new IdentityArrayList<Window>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
        int blockedWindowsCount = blockedWindows.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
        for (int i = 0; i < blockedWindowsCount; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
            Window w = blockedWindows.get(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
            save.add(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
            unblockWindow(w); // also removes w from blockedWindows
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
        // ... and only after that check if they should be blocked
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
        // by another dialogs
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
        for (int i = 0; i < blockedWindowsCount; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
            Window w = save.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
            if ((w instanceof Dialog) && ((Dialog)w).isModal_NoClientCode()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
                Dialog d = (Dialog)w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
                d.modalShow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
                checkShouldBeBlocked(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
     * Returns whether the given top-level window should be blocked by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
     * this dialog. Note, that the given window can be also a modal dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
     * and it should block this dialog, but this method do not take such
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
     * situations into consideration (such checks are performed in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
     * modalShow() and modalHide() methods).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
     * This method should be called on the getTreeLock() lock.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
    boolean shouldBlock(Window w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
        if (!isVisible_NoClientCode() ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
            (!w.isVisible_NoClientCode() && !w.isInShow) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
            isInHide ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
            (w == this) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
            !isModal_NoClientCode())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
        if ((w instanceof Dialog) && ((Dialog)w).isInHide) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
        // check if w is from children hierarchy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
        // fix for 6271546: we should also take into consideration child hierarchies
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
        // of this dialog's blockers
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
        Window blockerToCheck = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
        while (blockerToCheck != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
            Component c = w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
            while ((c != null) && (c != blockerToCheck)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
                c = c.getParent_NoClientCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
            if (c == blockerToCheck) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
            blockerToCheck = blockerToCheck.getModalBlocker();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
        switch (modalityType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
            case MODELESS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
            case DOCUMENT_MODAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
                if (w.isModalExcluded(ModalExclusionType.APPLICATION_EXCLUDE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
                    // application- and toolkit-excluded windows are not blocked by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
                    // document-modal dialogs from outside their children hierarchy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
                    Component c = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
                    while ((c != null) && (c != w)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
                        c = c.getParent_NoClientCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
                    return c == w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
                    return getDocumentRoot() == w.getDocumentRoot();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
            case APPLICATION_MODAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
                return !w.isModalExcluded(ModalExclusionType.APPLICATION_EXCLUDE) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
                    (appContext == w.appContext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
            case TOOLKIT_MODAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
                return !w.isModalExcluded(ModalExclusionType.TOOLKIT_EXCLUDE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
     * Adds the given top-level window to the list of blocked
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
     * windows for this dialog and marks it as modal blocked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
     * If the window is already blocked by some modal dialog,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
     * does nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
    void blockWindow(Window w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
        if (!w.isModalBlocked()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
            w.setModalBlocked(this, true, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
            blockedWindows.add(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
    void blockWindows(java.util.List<Window> toBlock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
        DialogPeer dpeer = (DialogPeer)peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
        if (dpeer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
        Iterator<Window> it = toBlock.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
        while (it.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
            Window w = it.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
            if (!w.isModalBlocked()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
                w.setModalBlocked(this, true, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
                it.remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
        dpeer.blockWindows(toBlock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
        blockedWindows.addAll(toBlock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
     * Removes the given top-level window from the list of blocked
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
     * windows for this dialog and marks it as unblocked. If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
     * window is not modal blocked, does nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
    void unblockWindow(Window w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
        if (w.isModalBlocked() && blockedWindows.contains(w)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
            blockedWindows.remove(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
            w.setModalBlocked(this, false, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
     * Checks if any other modal dialog D blocks the given window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
     * If such D exists, mark the window as blocked by D.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
    static void checkShouldBeBlocked(Window w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
        synchronized (w.getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
            for (int i = 0; i < modalDialogs.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
                Dialog modalDialog = modalDialogs.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
                if (modalDialog.shouldBlock(w)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
                    modalDialog.blockWindow(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
16099
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1610
    private void checkModalityPermission(ModalityType mt) {
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1611
        if (mt == ModalityType.TOOLKIT_MODAL) {
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1612
            SecurityManager sm = System.getSecurityManager();
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1613
            if (sm != null) {
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1614
                sm.checkPermission(
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1615
                    SecurityConstants.AWT.TOOLKIT_MODALITY_PERMISSION
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1616
                );
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1617
            }
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1618
        }
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1619
    }
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1620
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
        throws ClassNotFoundException, IOException, HeadlessException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
        GraphicsEnvironment.checkHeadless();
16099
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1625
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1626
        java.io.ObjectInputStream.GetField fields =
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1627
            s.readFields();
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1628
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1629
        ModalityType localModalityType = (ModalityType)fields.get("modalityType", null);
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1630
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1631
        try {
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1632
            checkModalityPermission(localModalityType);
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1633
        } catch (AccessControlException ace) {
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1634
            localModalityType = DEFAULT_MODALITY_TYPE;
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1635
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
        // in 1.5 or earlier modalityType was absent, so use "modal" instead
16099
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1638
        if (localModalityType == null) {
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1639
            this.modal = fields.get("modal", false);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
            setModal(modal);
16103
c9ffd920e3f0 8004341: Two JCK tests fails with 7u11 b06
denis
parents: 16100
diff changeset
  1641
        } else {
c9ffd920e3f0 8004341: Two JCK tests fails with 7u11 b06
denis
parents: 16100
diff changeset
  1642
            this.modalityType = localModalityType;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
16099
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1645
        this.resizable = fields.get("resizable", true);
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1646
        this.undecorated = fields.get("undecorated", false);
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1647
        this.title = (String)fields.get("title", "");
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1648
15318
607db339afcc 8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents: 13652
diff changeset
  1649
        blockedWindows = new IdentityArrayList<>();
16099
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1650
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1651
        SunToolkit.checkAndSetPolicy(this);
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1652
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1653
        initialized = true;
fb978a77b3e7 7201064: Better dialogue checking
denis
parents: 13652
diff changeset
  1654
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
     * --- Accessibility Support ---
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
     * Gets the AccessibleContext associated with this Dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
     * For dialogs, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
     * AccessibleAWTDialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
     * A new AccessibleAWTDialog instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
     * @return an AccessibleAWTDialog that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
     *         AccessibleContext of this Dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
            accessibleContext = new AccessibleAWTDialog();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
     * <code>Dialog</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
     * Java Accessibility API appropriate to dialog user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
    protected class AccessibleAWTDialog extends AccessibleAWTWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
         * JDK 1.3 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1690
        private static final long serialVersionUID = 4837230331833941201L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1694
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1695
         * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1696
         * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1697
         * @see AccessibleRole
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1698
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1699
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1700
            return AccessibleRole.DIALOG;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1701
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1702
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1703
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1704
         * Get the state of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1705
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1706
         * @return an instance of AccessibleStateSet containing the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1707
         * state set of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1708
         * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1709
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1710
        public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1711
            AccessibleStateSet states = super.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1712
            if (getFocusOwner() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1713
                states.add(AccessibleState.ACTIVE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1714
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1715
            if (isModal()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1716
                states.add(AccessibleState.MODAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1717
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1718
            if (isResizable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1719
                states.add(AccessibleState.RESIZABLE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1720
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1721
            return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1722
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1723
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1724
    } // inner class AccessibleAWTDialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1725
}