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