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