jdk/src/share/classes/java/awt/Dialog.java
author alanb
Mon, 05 Oct 2009 16:45:55 +0100
changeset 3956 2586d23078e4
parent 3084 67ca55732362
child 5506 202f599c92aa
permissions -rw-r--r--
6854954: Eliminate static dependency on java.awt.AWTPermission Reviewed-by: mullan, mchung, anthony
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
1183
80d6aafba03a 6682046: Mixing code does not always recalculate shapes correctly when resizing components
anthony
parents: 2
diff changeset
     2
 * Copyright 1995-2008 Sun Microsystems, Inc.  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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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 volatile boolean keepBlockingEDT = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    private transient volatile boolean keepBlockingCT = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    private transient ModalEventFilter modalFilter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * Indicates that this dialog is being hidden. This flag is set to true at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * the beginning of hide() and to false at the end of hide().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @see #hide()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * @see #hideAndDisposePreHandler()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @see #hideAndDisposeHandler()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * @see #shouldBlock()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    transient volatile boolean isInHide = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * Indicates that this dialog is being disposed. This flag is set to true at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * the beginning of doDispose() and to false at the end of doDispose().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * @see #hide()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * @see #hideAndDisposePreHandler()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * @see #hideAndDisposeHandler()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * @see #doDispose()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    transient volatile boolean isInDispose = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    private static final String base = "dialog";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    private static int nameCounter = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    private static final long serialVersionUID = 5920926903803293709L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * Constructs an initially invisible, modeless <code>Dialog</code> with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * the specified owner <code>Frame</code> and an empty title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * @param owner the owner of the dialog or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     *     this dialog has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     *    <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     *    <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @see Component#setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @see Component#setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     public Dialog(Frame owner) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
         this(owner, "", false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * Constructs an initially invisible <code>Dialog</code> with the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * owner <code>Frame</code> and modality and an empty title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * @param owner the owner of the dialog or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     *     this dialog has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * @param modal specifes whether dialog blocks user input to other top-level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     *     windows when shown. If <code>false</code>, the dialog is <code>MODELESS</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     *     if <code>true</code>, the modality type property is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     *     <code>DEFAULT_MODALITY_TYPE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     *    <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * @see java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     public Dialog(Frame owner, boolean modal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
         this(owner, "", modal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * Constructs an initially invisible, modeless <code>Dialog</code> with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     * the specified owner <code>Frame</code> and title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * @param owner the owner of the dialog or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     *     this dialog has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * @param title the title of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     *     has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * @exception IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     *     <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * @see Component#setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * @see Component#setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     public Dialog(Frame owner, String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
         this(owner, title, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * Constructs an initially invisible <code>Dialog</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * specified owner <code>Frame</code>, title and modality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * @param owner the owner of the dialog or <code>null</code> if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     *     this dialog has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * @param title the title of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     *     has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * @param modal specifes whether dialog blocks user input to other top-level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     *     windows when shown. If <code>false</code>, the dialog is <code>MODELESS</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     *     if <code>true</code>, the modality type property is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     *     <code>DEFAULT_MODALITY_TYPE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     *    <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     *    <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @see java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * @see Component#setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * @see Component#setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     public Dialog(Frame owner, String title, boolean modal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
         this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * Constructs an initially invisible <code>Dialog</code> with the specified owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * <code>Frame</code>, title, modality, and <code>GraphicsConfiguration</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * @param owner the owner of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     *     has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @param title the title of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     *     has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * @param modal specifes whether dialog blocks user input to other top-level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     *     windows when shown. If <code>false</code>, the dialog is <code>MODELESS</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     *     if <code>true</code>, the modality type property is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     *     <code>DEFAULT_MODALITY_TYPE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * @param gc the <code>GraphicsConfiguration</code> of the target screen device;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     *     if <code>null</code>, the default system <code>GraphicsConfiguration</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     *     is assumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * @exception java.lang.IllegalArgumentException if <code>gc</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     *     is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * @see java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * @see Component#setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * @see Component#setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     public Dialog(Frame owner, String title, boolean modal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                   GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
         this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * Constructs an initially invisible, modeless <code>Dialog</code> with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * the specified owner <code>Dialog</code> and an empty title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * @param owner the owner of the dialog or <code>null</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     *     dialog has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     *     <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     public Dialog(Dialog owner) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
         this(owner, "", false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * Constructs an initially invisible, modeless <code>Dialog</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * with the specified owner <code>Dialog</code> and title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * @param owner the owner of the dialog or <code>null</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *     has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * @param title the title of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     *     has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     *     <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     public Dialog(Dialog owner, String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
         this(owner, title, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * Constructs an initially invisible <code>Dialog</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * specified owner <code>Dialog</code>, title, and modality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * @param owner the owner of the dialog or <code>null</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     *     dialog has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * @param title the title of the dialog or <code>null</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     *     dialog has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * @param modal specifes whether dialog blocks user input to other top-level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     *     windows when shown. If <code>false</code>, the dialog is <code>MODELESS</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     *     if <code>true</code>, the modality type property is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     *     <code>DEFAULT_MODALITY_TYPE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * @exception IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     *    <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     *    <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * @see java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     public Dialog(Dialog owner, String title, boolean modal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
         this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * Constructs an initially invisible <code>Dialog</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * specified owner <code>Dialog</code>, title, modality and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     * <code>GraphicsConfiguration</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * @param owner the owner of the dialog or <code>null</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     *     dialog has no owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * @param title the title of the dialog or <code>null</code> if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     *     dialog has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * @param modal specifes whether dialog blocks user input to other top-level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     *     windows when shown. If <code>false</code>, the dialog is <code>MODELESS</code>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     *     if <code>true</code>, the modality type property is set to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     *     <code>DEFAULT_MODALITY_TYPE</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     * @param gc the <code>GraphicsConfiguration</code> of the target screen device;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     *     if <code>null</code>, the default system <code>GraphicsConfiguration</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     *     is assumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     * @exception java.lang.IllegalArgumentException if <code>gc</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     *    is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     *    <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * @see java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * @see java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * @see Component#setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * @see Component#setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     public Dialog(Dialog owner, String title, boolean modal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
                   GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
         this(owner, title, modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * Constructs an initially invisible, modeless <code>Dialog</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * specified owner <code>Window</code> and an empty title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * @param owner the owner of the dialog. The owner must be an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     *     {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     *     of their descendents or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     *     is not an instance of {@link java.awt.Dialog Dialog} or {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     *     java.awt.Frame Frame}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     *     <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
    public Dialog(Window owner) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        this(owner, null, ModalityType.MODELESS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * Constructs an initially invisible, modeless <code>Dialog</code> with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     * the specified owner <code>Window</code> and title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * @param owner the owner of the dialog. The owner must be an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     *    {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     *    of their descendents or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * @param title the title of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     *    has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     *    is not an instance of {@link java.awt.Dialog Dialog} or {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     *    java.awt.Frame Frame}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     *    <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     *    <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    public Dialog(Window owner, String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
        this(owner, title, ModalityType.MODELESS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * Constructs an initially invisible <code>Dialog</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * specified owner <code>Window</code> and modality and an empty title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * @param owner the owner of the dialog. The owner must be an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     *    {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     *    of their descendents or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * @param modalityType specifies whether dialog blocks input to other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     *    windows when shown. <code>null</code> value and unsupported modality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     *    types are equivalent to <code>MODELESS</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     *    is not an instance of {@link java.awt.Dialog Dialog} or {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     *    java.awt.Frame Frame}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     *    <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     *    <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     * @exception SecurityException if the calling thread does not have permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     *    to create modal dialogs with the given <code>modalityType</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * @see java.awt.Toolkit#isModalityTypeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    public Dialog(Window owner, ModalityType modalityType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        this(owner, null, modalityType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     * Constructs an initially invisible <code>Dialog</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * specified owner <code>Window</code>, title and modality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * @param owner the owner of the dialog. The owner must be an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     *     {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     *     of their descendents or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     * @param title the title of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     *     has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * @param modalityType specifies whether dialog blocks input to other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     *    windows when shown. <code>null</code> value and unsupported modality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     *    types are equivalent to <code>MODELESS</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     *     is not an instance of {@link java.awt.Dialog Dialog} or {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     *     java.awt.Frame Frame}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     *     <code>GraphicsConfiguration</code> is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * @exception SecurityException if the calling thread does not have permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     *     to create modal dialogs with the given <code>modalityType</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     * @see java.awt.Toolkit#isModalityTypeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    public Dialog(Window owner, String title, ModalityType modalityType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        super(owner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        if ((owner != null) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            !(owner instanceof Frame) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
            !(owner instanceof Dialog))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
            throw new IllegalArgumentException("Wrong parent window");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        this.title = title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
        setModalityType(modalityType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
        SunToolkit.checkAndSetPolicy(this, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * Constructs an initially invisible <code>Dialog</code> with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * specified owner <code>Window</code>, title, modality and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * <code>GraphicsConfiguration</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * @param owner the owner of the dialog. The owner must be an instance of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     *     {@link java.awt.Dialog Dialog}, {@link java.awt.Frame Frame}, any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     *     of their descendents or <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * @param title the title of the dialog or <code>null</code> if this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     *     has no title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * @param modalityType specifies whether dialog blocks input to other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     *    windows when shown. <code>null</code> value and unsupported modality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     *    types are equivalent to <code>MODELESS</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * @param gc the <code>GraphicsConfiguration</code> of the target screen device;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     *     if <code>null</code>, the default system <code>GraphicsConfiguration</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     *     is assumed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     * @exception java.lang.IllegalArgumentException if the <code>owner</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     *     is not an instance of {@link java.awt.Dialog Dialog} or {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     *     java.awt.Frame Frame}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * @exception java.lang.IllegalArgumentException if <code>gc</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     *     is not from a screen device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * @exception HeadlessException when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     *     <code>GraphicsEnvironment.isHeadless()</code> returns <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     * @exception SecurityException if the calling thread does not have permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     *     to create modal dialogs with the given <code>modalityType</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * @see java.awt.Dialog.ModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * @see java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * @see java.awt.Toolkit#isModalityTypeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
    public Dialog(Window owner, String title, ModalityType modalityType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
                  GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
        super(owner, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        if ((owner != null) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
            !(owner instanceof Frame) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
            !(owner instanceof Dialog))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
            throw new IllegalArgumentException("wrong owner window");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
        this.title = title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
        setModalityType(modalityType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
        SunToolkit.checkAndSetPolicy(this, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * Construct a name for this component.  Called by getName() when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     * name is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    String constructComponentName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        synchronized (Dialog.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
            return base + nameCounter++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     * Makes this Dialog displayable by connecting it to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * a native screen resource.  Making a dialog displayable will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     * cause any of its children to be made displayable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     * This method is called internally by the toolkit and should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * not be called directly by programs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * @see Component#isDisplayable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     * @see #removeNotify
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
    public void addNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
            if (parent != null && parent.getPeer() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                parent.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
            if (peer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
                peer = getToolkit().createDialog(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
            super.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
     * Indicates whether the dialog is modal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     * This method is obsolete and is kept for backwards compatiblity only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * Use {@link #getModalityType getModalityType()} instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * @return    <code>true</code> if this dialog window is modal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     *            <code>false</code> otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * @see       java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     * @see       java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * @see       java.awt.Dialog#setModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * @see       java.awt.Dialog#getModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * @see       java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
    public boolean isModal() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        return isModal_NoClientCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
    final boolean isModal_NoClientCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        return modalityType != ModalityType.MODELESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     * Specifies whether this dialog should be modal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * This method is obsolete and is kept for backwards compatibility only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     * Use {@link #setModalityType setModalityType()} instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     * Note: changing modality of the visible dialog may have no effect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     * until it is hidden and then shown again.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     * @param modal specifies whether dialog blocks input to other windows
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
     *     when shown; calling to <code>setModal(true)</code> is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
     *     <code>setModalityType(Dialog.DEFAULT_MODALITY_TYPE)</code>, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     *     calling to <code>setModal(false)</code> is equvivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     *     <code>setModalityType(Dialog.ModalityType.MODELESS)</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * @see       java.awt.Dialog#DEFAULT_MODALITY_TYPE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * @see       java.awt.Dialog.ModalityType#MODELESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     * @see       java.awt.Dialog#isModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     * @see       java.awt.Dialog#getModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     * @see       java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     * @since     1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
    public void setModal(boolean modal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
        this.modal = modal;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
        setModalityType(modal ? DEFAULT_MODALITY_TYPE : ModalityType.MODELESS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
     * Returns the modality type of this dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
     * @return modality type of this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     * @see java.awt.Dialog#setModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
    public ModalityType getModalityType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
        return modalityType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
     * Sets the modality type for this dialog. See {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
     * java.awt.Dialog.ModalityType ModalityType} for possible modality types.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     * If the given modality type is not supported, <code>MODELESS</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * is used. You may want to call <code>getModalityType()</code> after calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     * this method to ensure that the modality type has been set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * Note: changing modality of the visible dialog may have no effect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * until it is hidden and then shown again.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     * @param type specifies whether dialog blocks input to other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
     *     windows when shown. <code>null</code> value and unsupported modality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     *     types are equivalent to <code>MODELESS</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * @exception SecurityException if the calling thread does not have permission
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     *     to create modal dialogs with the given <code>modalityType</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     * @see       java.awt.Dialog#getModalityType
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     * @see       java.awt.Toolkit#isModalityTypeSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     * @since     1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
    public void setModalityType(ModalityType type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
        if (type == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
            type = Dialog.ModalityType.MODELESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        if (!Toolkit.getDefaultToolkit().isModalityTypeSupported(type)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
            type = Dialog.ModalityType.MODELESS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        if (modalityType == type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        if (type == ModalityType.TOOLKIT_MODAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
            SecurityManager sm = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
            if (sm != null) {
3956
2586d23078e4 6854954: Eliminate static dependency on java.awt.AWTPermission
alanb
parents: 3084
diff changeset
   859
                sm.checkPermission(SecurityConstants.AWT.TOOLKIT_MODALITY_PERMISSION);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        modalityType = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        modal = (modalityType != ModalityType.MODELESS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
     * Gets the title of the dialog. The title is displayed in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     * dialog's border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
     * @return    the title of this dialog window. The title may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     *            <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
     * @see       java.awt.Dialog#setTitle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    public String getTitle() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        return title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
     * Sets the title of the Dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
     * @param title the title displayed in the dialog's border;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
         * a null value results in an empty title
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
     * @see #getTitle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    public void setTitle(String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        String oldTitle = this.title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
            this.title = title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
            DialogPeer peer = (DialogPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
                peer.setTitle(title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
        firePropertyChange("title", oldTitle, title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
     * @return true if we actually showed, false if we just called toFront()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
    private boolean conditionalShow(Component toFocus, AtomicLong time) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
        boolean retval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
        closeSplashScreen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
            if (peer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
            validate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
            if (visible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
                toFront();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                retval = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                visible = retval = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
                // check if this dialog should be modal blocked BEFORE calling peer.show(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
                // otherwise, a pair of FOCUS_GAINED and FOCUS_LOST may be mistakenly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
                // generated for the dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
                if (!isModal()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
                    checkShouldBeBlocked(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
                    modalDialogs.add(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
                    modalShow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
                if (toFocus != null && time != null && isFocusable() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
                    isEnabled() && !isModalBlocked()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                    // keep the KeyEvents from being dispatched
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
                    // until the focus has been transfered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
                    time.set(Toolkit.getEventQueue().getMostRecentEventTimeEx());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
                    KeyboardFocusManager.getCurrentKeyboardFocusManager().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
                        enqueueKeyEvents(time.get(), toFocus);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
                // This call is required as the show() method of the Dialog class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                // does not invoke the super.show(). So wried... :(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
                mixOnShowing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
1964
934568dfe859 6749920: Cleanup AWT peer interfaces
rkennke
parents: 1183
diff changeset
   938
                peer.setVisible(true); // now guaranteed never to block
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
                if (isModalBlocked()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
                    modalBlocker.toFront();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                setLocationByPlatform(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                for (int i = 0; i < ownedWindowList.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                    Window child = ownedWindowList.elementAt(i).get();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
                    if ((child != null) && child.showWithParent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
                        child.show();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
                        child.showWithParent = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
                    }       // endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
                }   // endfor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
                Window.updateChildFocusableWindowState(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
                createHierarchyEvents(HierarchyEvent.HIERARCHY_CHANGED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                                      this, parent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
                                      HierarchyEvent.SHOWING_CHANGED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
                                      Toolkit.enabledOnToolkit(AWTEvent.HIERARCHY_EVENT_MASK));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
                if (componentListener != null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
                        (eventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
                        Toolkit.enabledOnToolkit(AWTEvent.COMPONENT_EVENT_MASK)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
                    ComponentEvent e =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
                        new ComponentEvent(this, ComponentEvent.COMPONENT_SHOWN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
                    Toolkit.getEventQueue().postEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
        if (retval && (state & OPENED) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
            postWindowEvent(WindowEvent.WINDOW_OPENED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
            state |= OPENED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
        return retval;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
     * Shows or hides this {@code Dialog} depending on the value of parameter
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
     * {@code b}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
     * @param b if {@code true}, makes the {@code Dialog} visible,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
     * otherwise hides the {@code Dialog}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
     * If the dialog and/or its owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     * are not yet displayable, both are made displayable.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     * dialog will be validated prior to being made visible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
     * If {@code false}, hides the {@code Dialog} and then causes {@code setVisible(true)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
     * to return if it is currently blocked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
     * <b>Notes for modal dialogs</b>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
     * <ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     * <li>{@code setVisible(true)}:  If the dialog is not already
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
     * visible, this call will not return until the dialog is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
     * hidden by calling {@code setVisible(false)} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
     * {@code dispose}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
     * <li>{@code setVisible(false)}:  Hides the dialog and then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
     * returns on {@code setVisible(true)} if it is currently blocked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
     * <li>It is OK to call this method from the event dispatching
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
     * thread because the toolkit ensures that other events are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
     * not blocked while this method is blocked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     * @see java.awt.Window#setVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     * @see java.awt.Window#dispose
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     * @see java.awt.Component#isDisplayable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     * @see java.awt.Component#validate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     * @see java.awt.Dialog#isModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
    public void setVisible(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
        super.setVisible(b);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
    * Stores the app context on which event dispatch thread the dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
    * is being shown. Initialized in show(), used in hideAndDisposeHandler()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
    transient private AppContext showAppContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
     * Makes the {@code Dialog} visible. If the dialog and/or its owner
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
     * are not yet displayable, both are made displayable.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
     * dialog will be validated prior to being made visible.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
     * If the dialog is already visible, this will bring the dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
     * to the front.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
     * If the dialog is modal and is not already visible, this call
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
     * will not return until the dialog is hidden by calling hide or
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     * dispose. It is permissible to show modal dialogs from the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     * dispatching thread because the toolkit will ensure that another
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
     * event pump runs while the one which invoked this method is blocked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
     * @see Component#hide
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
     * @see Component#isDisplayable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     * @see Component#validate
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     * @see #isModal
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     * @see Window#setVisible(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
     * @deprecated As of JDK version 1.5, replaced by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
     * {@link #setVisible(boolean) setVisible(boolean)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
    public void show() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
        beforeFirstShow = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
        if (!isModal()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
            conditionalShow(null, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
            // Set this variable before calling conditionalShow(). That
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
            // way, if the Dialog is hidden right after being shown, we
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
            // won't mistakenly block this thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
            keepBlockingEDT = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
            keepBlockingCT = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
            // Store the app context on which this dialog is being shown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
            // Event dispatch thread of this app context will be sleeping until
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
            // we wake it by any event from hideAndDisposeHandler().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
            showAppContext = AppContext.getAppContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
            AtomicLong time = new AtomicLong();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
            Component predictedFocusOwner = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
                predictedFocusOwner = getMostRecentFocusOwner();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
                if (conditionalShow(predictedFocusOwner, time)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
                    // We have two mechanisms for blocking: 1. If we're on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
                    // EventDispatchThread, start a new event pump. 2. If we're
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
                    // on any other thread, call wait() on the treelock.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
                    modalFilter = ModalEventFilter.createFilterForDialog(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
                    final Runnable pumpEventsForFilter = new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
                        public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
                            EventDispatchThread dispatchThread =
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
                                (EventDispatchThread)Thread.currentThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
                            dispatchThread.pumpEventsForFilter(new Conditional() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
                                public boolean evaluate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
                                    synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
                                        return keepBlockingEDT && windowClosingException == null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
                            }, modalFilter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
                    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
                    // if this dialog is toolkit-modal, the filter should be added
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
                    // to all EDTs (for all AppContexts)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
                    if (modalityType == ModalityType.TOOLKIT_MODAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                        Iterator it = AppContext.getAppContexts().iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
                        while (it.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
                            AppContext appContext = (AppContext)it.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
                            if (appContext == showAppContext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
                                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
                            EventQueue eventQueue = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
                            // it may occur that EDT for appContext hasn't been started yet, so
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
                            // we post an empty invocation event to trigger EDT initialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
                            Runnable createEDT = new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
                                public void run() {};
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
                            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
                            eventQueue.postEvent(new InvocationEvent(this, createEDT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
                            EventDispatchThread edt = eventQueue.getDispatchThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
                            edt.addEventFilter(modalFilter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
                    modalityPushed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
                        if (EventQueue.isDispatchThread()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
                            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
                             * dispose SequencedEvent we are dispatching on current
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
                             * AppContext, to prevent us from hang.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
                             *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
                             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
                            // BugId 4531693 (son@sparc.spb.su)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
                            SequencedEvent currentSequencedEvent = KeyboardFocusManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
                                getCurrentKeyboardFocusManager().getCurrentSequencedEvent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
                            if (currentSequencedEvent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
                                currentSequencedEvent.dispose();
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
                             * Event processing is done inside doPrivileged block so that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
                             * it wouldn't matter even if user code is on the stack
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
                             * Fix for BugId 6300270
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
                             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
                             AccessController.doPrivileged(new PrivilegedAction() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
                                     public Object run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
                                        pumpEventsForFilter.run();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
                                        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
                                     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
                             });
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
                        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
                            synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
                                Toolkit.getEventQueue().postEvent(new PeerEvent(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
                                                                                pumpEventsForFilter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
                                                                                PeerEvent.PRIORITY_EVENT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
                                while (keepBlockingCT && windowClosingException == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
                                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
                                        getTreeLock().wait();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
                                    } catch (InterruptedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
                                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
                                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
                                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
                    } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
                        modalityPopped();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
                    // if this dialog is toolkit-modal, its filter must be removed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
                    // from all EDTs (for all AppContexts)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
                    if (modalityType == ModalityType.TOOLKIT_MODAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
                        Iterator it = AppContext.getAppContexts().iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
                        while (it.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
                            AppContext appContext = (AppContext)it.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
                            if (appContext == showAppContext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
                                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
                            EventQueue eventQueue = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
                            EventDispatchThread edt = eventQueue.getDispatchThread();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
                            edt.removeEventFilter(modalFilter);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
                    if (windowClosingException != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
                        windowClosingException.fillInStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
                        throw windowClosingException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
            } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
                if (predictedFocusOwner != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
                    // Restore normal key event dispatching
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
                    KeyboardFocusManager.getCurrentKeyboardFocusManager().
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
                        dequeueKeyEvents(time.get(), predictedFocusOwner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
    final void modalityPushed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
        Toolkit tk = Toolkit.getDefaultToolkit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
        if (tk instanceof SunToolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
            SunToolkit stk = (SunToolkit)tk;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
            stk.notifyModalityPushed(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
    final void modalityPopped() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
        Toolkit tk = Toolkit.getDefaultToolkit();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
        if (tk instanceof SunToolkit) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
            SunToolkit stk = (SunToolkit)tk;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
            stk.notifyModalityPopped(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
    void interruptBlocking() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
        if (isModal()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
            disposeImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
        } else if (windowClosingException != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
            windowClosingException.fillInStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
            windowClosingException.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
            windowClosingException = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
    final class WakingRunnable implements Runnable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
        public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
            synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
                keepBlockingCT = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
                getTreeLock().notifyAll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
    private void hideAndDisposePreHandler() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
        isInHide = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
            if (keepBlockingEDT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
                modalHide();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
                // dialog can be shown and then disposed before its
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
                // modal filter is created
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
                if (modalFilter != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
                    modalFilter.disable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1214
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
                modalDialogs.remove(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
    private void hideAndDisposeHandler() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
            if (keepBlockingEDT) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
                keepBlockingEDT = false;
2470
45c5e082f53d 6809233: Modal dialog blocks calling thread after it is hidden and disposed
rkennke
parents: 1964
diff changeset
  1223
                PeerEvent wakingEvent = new PeerEvent(getToolkit(), new WakingRunnable(), PeerEvent.PRIORITY_EVENT);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
                AppContext curAppContext = AppContext.getAppContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
                if (showAppContext != curAppContext) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
                    // Wake up event dispatch thread on which the dialog was
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
                    // initially shown
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
                    SunToolkit.postEvent(showAppContext, wakingEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
                    showAppContext = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
                    Toolkit.getEventQueue().postEvent(wakingEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
        isInHide = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
     * Hides the Dialog and then causes {@code show} to return if it is currently
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
     * blocked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
     * @see Window#show
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
     * @see Window#dispose
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
     * @see Window#setVisible(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
     * @deprecated As of JDK version 1.5, replaced by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
     * {@link #setVisible(boolean) setVisible(boolean)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
    public void hide() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
        hideAndDisposePreHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
        super.hide();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
        // fix for 5048370: if hide() is called from super.doDispose(), then
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
        // hideAndDisposeHandler() should not be called here as it will be called
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
        // at the end of doDispose()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
        if (!isInDispose) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
            hideAndDisposeHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
     * Disposes the Dialog and then causes show() to return if it is currently
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
     * blocked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
    void doDispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
        // fix for 5048370: set isInDispose flag to true to prevent calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
        // to hideAndDisposeHandler() from hide()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
        isInDispose = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
        super.doDispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
        hideAndDisposeHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
        isInDispose = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
     * If this dialog is modal and blocks some windows, then all of them are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
     * also sent to the back to keep them below the blocking dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
     * @see java.awt.Window#toBack
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
    public void toBack() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
        super.toBack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
        if (visible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
            synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
                for (Window w : blockedWindows) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
                    w.toBack_NoClientCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
     * Indicates whether this dialog is resizable by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
     * By default, all dialogs are initially resizable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
     * @return    <code>true</code> if the user can resize the dialog;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
     *            <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
     * @see       java.awt.Dialog#setResizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
    public boolean isResizable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
        return resizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
     * Sets whether this dialog is resizable by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
     * @param     resizable <code>true</code> if the user can
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
     *                 resize this dialog; <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
     * @see       java.awt.Dialog#isResizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
    public void setResizable(boolean resizable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
        boolean testvalid = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
            this.resizable = resizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
            DialogPeer peer = (DialogPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
                peer.setResizable(resizable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
                testvalid = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
        // On some platforms, changing the resizable state affects
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
        // the insets of the Dialog. If we could, we'd call invalidate()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
        // from the peer, but we need to guarantee that we're not holding
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
        // 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
  1324
        if (testvalid) {
80d6aafba03a 6682046: Mixing code does not always recalculate shapes correctly when resizing components
anthony
parents: 2
diff changeset
  1325
            invalidateIfValid();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
     * Disables or enables decorations for this dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
     * This method can only be called while the dialog is not displayable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
     * @param  undecorated <code>true</code> if no dialog decorations are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
     *         to be enabled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
     *         <code>false</code> if dialog decorations are to be enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
     * @throws <code>IllegalComponentStateException</code> if the dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
     *         is displayable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
     * @see    #isUndecorated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
     * @see    Component#isDisplayable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
    public void setUndecorated(boolean undecorated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
        /* Make sure we don't run in the middle of peer creation.*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
            if (isDisplayable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
                throw new IllegalComponentStateException("The dialog is displayable.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
            this.undecorated = undecorated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
     * Indicates whether this dialog is undecorated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
     * By default, all dialogs are initially decorated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
     * @return    <code>true</code> if dialog is undecorated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
     *                        <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
     * @see       java.awt.Dialog#setUndecorated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
    public boolean isUndecorated() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
        return undecorated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
     * Returns a string representing the state of this dialog. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
     * method is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
     * implementations. The returned string may be empty but may not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
     * <code>null</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
     * @return    the parameter string of this dialog window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
        String str = super.paramString() + "," + modalityType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
        if (title != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
            str += ",title=" + title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
        return str;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
     * Initialize JNI field and method IDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
     * --- Modality support ---
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
     * This method is called only for modal dialogs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
     * Goes through the list of all visible top-level windows and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
     * divide them into three distinct groups: blockers of this dialog,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
     * blocked by this dialog and all others. Then blocks this dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
     * by first met dialog from the first group (if any) and blocks all
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
     * the windows from the second group.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
    void modalShow() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
        // find all the dialogs that block this one
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
        IdentityArrayList<Dialog> blockers = new IdentityArrayList<Dialog>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
        for (Dialog d : modalDialogs) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
            if (d.shouldBlock(this)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
                Window w = d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
                while ((w != null) && (w != this)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
                    w = (Window)(w.getOwner_NoClientCode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
                if ((w == this) || !shouldBlock(d) || (modalityType.compareTo(d.getModalityType()) < 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
                    blockers.add(d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1411
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1412
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1413
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1414
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1415
        // add all blockers' blockers to blockers :)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1416
        for (int i = 0; i < blockers.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1417
            Dialog blocker = blockers.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1418
            if (blocker.isModalBlocked()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1419
                Dialog blockerBlocker = blocker.getModalBlocker();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1420
                if (!blockers.contains(blockerBlocker)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1421
                    blockers.add(i + 1, blockerBlocker);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1422
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1423
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1424
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1425
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1426
        if (blockers.size() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1427
            blockers.get(0).blockWindow(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1428
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1429
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1430
        // find all windows from blockers' hierarchies
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1431
        IdentityArrayList<Window> blockersHierarchies = new IdentityArrayList<Window>(blockers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1432
        int k = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1433
        while (k < blockersHierarchies.size()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1434
            Window w = blockersHierarchies.get(k);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1435
            Window[] ownedWindows = w.getOwnedWindows_NoClientCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1436
            for (Window win : ownedWindows) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1437
                blockersHierarchies.add(win);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1438
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1439
            k++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1440
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1441
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1442
        java.util.List<Window> toBlock = new IdentityLinkedList<Window>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1443
        // block all windows from scope of blocking except from blockers' hierarchies
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1444
        IdentityArrayList<Window> unblockedWindows = Window.getAllUnblockedWindows();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1445
        for (Window w : unblockedWindows) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1446
            if (shouldBlock(w) && !blockersHierarchies.contains(w)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1447
                if ((w instanceof Dialog) && ((Dialog)w).isModal_NoClientCode()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1448
                    Dialog wd = (Dialog)w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1449
                    if (wd.shouldBlock(this) && (modalDialogs.indexOf(wd) > modalDialogs.indexOf(this))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1450
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1451
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1452
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1453
                toBlock.add(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1454
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1455
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1456
        blockWindows(toBlock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1457
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1458
        if (!isModalBlocked()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1459
            updateChildrenBlocking();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1460
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1461
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1462
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1463
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1464
     * This method is called only for modal dialogs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1465
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1466
     * Unblocks all the windows blocked by this modal dialog. After
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1467
     * each of them has been unblocked, it is checked to be blocked by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1468
     * any other modal dialogs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1469
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1470
    void modalHide() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1471
        // we should unblock all the windows first...
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1472
        IdentityArrayList<Window> save = new IdentityArrayList<Window>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1473
        int blockedWindowsCount = blockedWindows.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1474
        for (int i = 0; i < blockedWindowsCount; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1475
            Window w = blockedWindows.get(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1476
            save.add(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1477
            unblockWindow(w); // also removes w from blockedWindows
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1478
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1479
        // ... and only after that check if they should be blocked
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1480
        // by another dialogs
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1481
        for (int i = 0; i < blockedWindowsCount; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1482
            Window w = save.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1483
            if ((w instanceof Dialog) && ((Dialog)w).isModal_NoClientCode()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1484
                Dialog d = (Dialog)w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1485
                d.modalShow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1486
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1487
                checkShouldBeBlocked(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1488
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1489
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1490
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1491
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1492
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1493
     * Returns whether the given top-level window should be blocked by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1494
     * this dialog. Note, that the given window can be also a modal dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1495
     * and it should block this dialog, but this method do not take such
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1496
     * situations into consideration (such checks are performed in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1497
     * modalShow() and modalHide() methods).
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1498
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1499
     * This method should be called on the getTreeLock() lock.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1500
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1501
    boolean shouldBlock(Window w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1502
        if (!isVisible_NoClientCode() ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1503
            (!w.isVisible_NoClientCode() && !w.isInShow) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1504
            isInHide ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1505
            (w == this) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1506
            !isModal_NoClientCode())
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1507
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1508
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1509
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1510
        if ((w instanceof Dialog) && ((Dialog)w).isInHide) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1511
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1512
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1513
        // check if w is from children hierarchy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1514
        // fix for 6271546: we should also take into consideration child hierarchies
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1515
        // of this dialog's blockers
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1516
        Window blockerToCheck = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1517
        while (blockerToCheck != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1518
            Component c = w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1519
            while ((c != null) && (c != blockerToCheck)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1520
                c = c.getParent_NoClientCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1521
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1522
            if (c == blockerToCheck) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1523
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1524
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1525
            blockerToCheck = blockerToCheck.getModalBlocker();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1526
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1527
        switch (modalityType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1528
            case MODELESS:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1529
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1530
            case DOCUMENT_MODAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1531
                if (w.isModalExcluded(ModalExclusionType.APPLICATION_EXCLUDE)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1532
                    // application- and toolkit-excluded windows are not blocked by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1533
                    // document-modal dialogs from outside their children hierarchy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1534
                    Component c = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1535
                    while ((c != null) && (c != w)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1536
                        c = c.getParent_NoClientCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1537
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1538
                    return c == w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1539
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1540
                    return getDocumentRoot() == w.getDocumentRoot();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1541
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1542
            case APPLICATION_MODAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1543
                return !w.isModalExcluded(ModalExclusionType.APPLICATION_EXCLUDE) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1544
                    (appContext == w.appContext);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1545
            case TOOLKIT_MODAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1546
                return !w.isModalExcluded(ModalExclusionType.TOOLKIT_EXCLUDE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1547
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1548
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1549
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1550
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1551
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1552
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1553
     * Adds the given top-level window to the list of blocked
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1554
     * windows for this dialog and marks it as modal blocked.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1555
     * If the window is already blocked by some modal dialog,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1556
     * does nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1557
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1558
    void blockWindow(Window w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1559
        if (!w.isModalBlocked()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1560
            w.setModalBlocked(this, true, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1561
            blockedWindows.add(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1562
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1563
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1564
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1565
    void blockWindows(java.util.List<Window> toBlock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1566
        DialogPeer dpeer = (DialogPeer)peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1567
        if (dpeer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1568
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1569
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1570
        Iterator<Window> it = toBlock.iterator();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1571
        while (it.hasNext()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1572
            Window w = it.next();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1573
            if (!w.isModalBlocked()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1574
                w.setModalBlocked(this, true, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1575
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1576
                it.remove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1577
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1578
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1579
        dpeer.blockWindows(toBlock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1580
        blockedWindows.addAll(toBlock);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1581
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1582
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1583
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1584
     * Removes the given top-level window from the list of blocked
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1585
     * windows for this dialog and marks it as unblocked. If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1586
     * window is not modal blocked, does nothing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1587
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1588
    void unblockWindow(Window w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1589
        if (w.isModalBlocked() && blockedWindows.contains(w)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1590
            blockedWindows.remove(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1591
            w.setModalBlocked(this, false, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1592
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1593
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1594
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1595
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1596
     * Checks if any other modal dialog D blocks the given window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1597
     * If such D exists, mark the window as blocked by D.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1598
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1599
    static void checkShouldBeBlocked(Window w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1600
        synchronized (w.getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1601
            for (int i = 0; i < modalDialogs.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1602
                Dialog modalDialog = modalDialogs.get(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1603
                if (modalDialog.shouldBlock(w)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1604
                    modalDialog.blockWindow(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1605
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1606
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1607
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1608
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1609
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1610
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1611
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1612
        throws ClassNotFoundException, IOException, HeadlessException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1613
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1614
        GraphicsEnvironment.checkHeadless();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1615
        s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1616
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1617
        // in 1.5 or earlier modalityType was absent, so use "modal" instead
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1618
        if (modalityType == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1619
            setModal(modal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1620
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1621
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1622
        blockedWindows = new IdentityArrayList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1623
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1624
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1625
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1626
     * --- Accessibility Support ---
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1627
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1628
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1629
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1630
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1631
     * Gets the AccessibleContext associated with this Dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1632
     * For dialogs, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1633
     * AccessibleAWTDialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1634
     * A new AccessibleAWTDialog instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1635
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1636
     * @return an AccessibleAWTDialog that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1637
     *         AccessibleContext of this Dialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1638
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1639
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1640
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1641
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1642
            accessibleContext = new AccessibleAWTDialog();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1643
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1644
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1645
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1646
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1647
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1648
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1649
     * <code>Dialog</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1650
     * Java Accessibility API appropriate to dialog user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1651
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1652
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1653
    protected class AccessibleAWTDialog extends AccessibleAWTWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1654
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1655
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1656
         * JDK 1.3 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1657
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1658
        private static final long serialVersionUID = 4837230331833941201L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1659
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1660
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1661
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1662
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1663
         * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1664
         * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1665
         * @see AccessibleRole
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1666
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1667
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1668
            return AccessibleRole.DIALOG;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1669
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1670
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1671
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1672
         * Get the state of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1673
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1674
         * @return an instance of AccessibleStateSet containing the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1675
         * state set of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1676
         * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1677
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1678
        public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1679
            AccessibleStateSet states = super.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1680
            if (getFocusOwner() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1681
                states.add(AccessibleState.ACTIVE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1682
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1683
            if (isModal()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1684
                states.add(AccessibleState.MODAL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1685
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1686
            if (isResizable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1687
                states.add(AccessibleState.RESIZABLE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1688
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1689
            return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1690
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1691
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1692
    } // inner class AccessibleAWTDialog
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1693
}