src/java.desktop/share/classes/java/awt/Frame.java
author serb
Mon, 09 Sep 2019 12:23:22 -0700
changeset 58325 d32a3b1ca84a
parent 47216 71c04702a3d5
permissions -rw-r--r--
8225372: accessibility errors in tables in java.desktop files Reviewed-by: aivanov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
58325
d32a3b1ca84a 8225372: accessibility errors in tables in java.desktop files
serb
parents: 47216
diff changeset
     2
 * Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4255
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4255
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4255
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4255
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4255
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
30471
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
    27
import java.awt.event.KeyEvent;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
    28
import java.awt.event.WindowEvent;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.peer.FramePeer;
30471
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
    30
import java.io.IOException;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
    31
import java.io.ObjectInputStream;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.io.ObjectOutputStream;
30471
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
    33
import java.io.Serializable;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
    34
import java.util.ArrayList;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
    35
import java.util.Vector;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
    36
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
    37
import javax.accessibility.AccessibleContext;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
    38
import javax.accessibility.AccessibleRole;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
    39
import javax.accessibility.AccessibleState;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
    40
import javax.accessibility.AccessibleStateSet;
36903
addc2e9d4bd4 8143227: Platform-Specific Desktop Features
azvegint
parents: 35667
diff changeset
    41
import javax.swing.WindowConstants;
30471
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
    42
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
    43
import sun.awt.AWTAccessor;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import sun.awt.SunToolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
/**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    47
 * A {@code Frame} is a top-level window with a title and a border.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * The size of the frame includes any area designated for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * border.  The dimensions of the border area may be obtained
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    51
 * using the {@code getInsets} method, however, since
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * these dimensions are platform-dependent, a valid insets
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * value cannot be obtained until the frame is made displayable
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    54
 * by either calling {@code pack} or {@code show}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * Since the border area is included in the overall size of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * frame, the border effectively obscures a portion of the frame,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * constraining the area available for rendering and/or displaying
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * subcomponents to the rectangle which has an upper-left corner
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    59
 * location of {@code (insets.left, insets.top)}, and has a size of
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    60
 * {@code width - (insets.left + insets.right)} by
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    61
 * {@code height - (insets.top + insets.bottom)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    63
 * The default layout for a frame is {@code BorderLayout}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    65
 * A frame may have its native decorations (i.e. {@code Frame}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    66
 * and {@code Titlebar}) turned off
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    67
 * with {@code setUndecorated}. This can only be done while the frame
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * is not {@link Component#isDisplayable() displayable}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    70
 * In a multi-screen environment, you can create a {@code Frame}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    71
 * on a different screen device by constructing the {@code Frame}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * with {@link #Frame(GraphicsConfiguration)} or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * {@link #Frame(String title, GraphicsConfiguration)}.  The
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    74
 * {@code GraphicsConfiguration} object is one of the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    75
 * {@code GraphicsConfiguration} objects of the target screen
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * In a virtual device multi-screen environment in which the desktop
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * area could span multiple physical screen devices, the bounds of all
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * configurations are relative to the virtual-coordinate system.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * origin of the virtual-coordinate system is at the upper left-hand
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * corner of the primary physical screen.  Depending on the location
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * of the primary screen in the virtual device, negative coordinates
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * are possible, as shown in the following figure.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * <p>
58325
d32a3b1ca84a 8225372: accessibility errors in tables in java.desktop files
serb
parents: 47216
diff changeset
    86
 * <img src="doc-files/MultiScreen.gif" alt="Diagram of virtual device
d32a3b1ca84a 8225372: accessibility errors in tables in java.desktop files
serb
parents: 47216
diff changeset
    87
 * encompassing three physical screens and one primary physical screen. The
d32a3b1ca84a 8225372: accessibility errors in tables in java.desktop files
serb
parents: 47216
diff changeset
    88
 * primary physical screen shows (0,0) coords while a different physical screen
d32a3b1ca84a 8225372: accessibility errors in tables in java.desktop files
serb
parents: 47216
diff changeset
    89
 * shows (-80,-100) coords." style="margin: 7px 10px;">
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    91
 * In such an environment, when calling {@code setLocation},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * you must pass a virtual coordinate to this method.  Similarly,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    93
 * calling {@code getLocationOnScreen} on a {@code Frame}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    94
 * returns virtual device coordinates.  Call the {@code getBounds}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    95
 * method of a {@code GraphicsConfiguration} to find its origin in
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 * the virtual coordinate system.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * The following code sets the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
    99
 * location of the {@code Frame} at (10, 10) relative
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * to the origin of the physical screen of the corresponding
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   101
 * {@code GraphicsConfiguration}.  If the bounds of the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   102
 * {@code GraphicsConfiguration} is not taken into account, the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   103
 * {@code Frame} location would be set at (10, 10) relative to the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * virtual-coordinate system and would appear on the primary physical
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 * screen, which might be different from the physical screen of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   106
 * specified {@code GraphicsConfiguration}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 *      Frame f = new Frame(GraphicsConfiguration gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 *      Rectangle bounds = gc.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 *      f.setLocation(10 + bounds.x, 10 + bounds.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * Frames are capable of generating the following types of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   116
 * {@code WindowEvent}s:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * <ul>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   118
 * <li>{@code WINDOW_OPENED}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   119
 * <li>{@code WINDOW_CLOSING}:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 *     <br>If the program doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 *     explicitly hide or dispose the window while processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 *     this event, the window close operation is canceled.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   123
 * <li>{@code WINDOW_CLOSED}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   124
 * <li>{@code WINDOW_ICONIFIED}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   125
 * <li>{@code WINDOW_DEICONIFIED}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   126
 * <li>{@code WINDOW_ACTIVATED}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   127
 * <li>{@code WINDOW_DEACTIVATED}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   128
 * <li>{@code WINDOW_GAINED_FOCUS}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   129
 * <li>{@code WINDOW_LOST_FOCUS}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   130
 * <li>{@code WINDOW_STATE_CHANGED}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 * @author      Sami Shaio
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * @see WindowEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 * @see Window#addWindowListener
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   136
 * @since       1.0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
public class Frame extends Window implements MenuContainer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    /* Note: These are being obsoleted;  programs should use the Cursor class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * variables going forward. See Cursor and Component.setCursor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
   /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   145
    * @deprecated   replaced by {@code Cursor.DEFAULT_CURSOR}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    public static final int     DEFAULT_CURSOR                  = Cursor.DEFAULT_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
   /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   152
    * @deprecated   replaced by {@code Cursor.CROSSHAIR_CURSOR}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    public static final int     CROSSHAIR_CURSOR                = Cursor.CROSSHAIR_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
   /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   158
    * @deprecated   replaced by {@code Cursor.TEXT_CURSOR}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    public static final int     TEXT_CURSOR                     = Cursor.TEXT_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
   /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   164
    * @deprecated   replaced by {@code Cursor.WAIT_CURSOR}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    public static final int     WAIT_CURSOR                     = Cursor.WAIT_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
   /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   170
    * @deprecated   replaced by {@code Cursor.SW_RESIZE_CURSOR}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    public static final int     SW_RESIZE_CURSOR                = Cursor.SW_RESIZE_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
   /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   176
    * @deprecated   replaced by {@code Cursor.SE_RESIZE_CURSOR}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    public static final int     SE_RESIZE_CURSOR                = Cursor.SE_RESIZE_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
   /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   182
    * @deprecated   replaced by {@code Cursor.NW_RESIZE_CURSOR}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    public static final int     NW_RESIZE_CURSOR                = Cursor.NW_RESIZE_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
   /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   188
    * @deprecated   replaced by {@code Cursor.NE_RESIZE_CURSOR}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    public static final int     NE_RESIZE_CURSOR                = Cursor.NE_RESIZE_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
   /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   194
    * @deprecated   replaced by {@code Cursor.N_RESIZE_CURSOR}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    public static final int     N_RESIZE_CURSOR                 = Cursor.N_RESIZE_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
   /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   200
    * @deprecated   replaced by {@code Cursor.S_RESIZE_CURSOR}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    public static final int     S_RESIZE_CURSOR                 = Cursor.S_RESIZE_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
   /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   206
    * @deprecated   replaced by {@code Cursor.W_RESIZE_CURSOR}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public static final int     W_RESIZE_CURSOR                 = Cursor.W_RESIZE_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
   /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   212
    * @deprecated   replaced by {@code Cursor.E_RESIZE_CURSOR}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    public static final int     E_RESIZE_CURSOR                 = Cursor.E_RESIZE_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
   /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   218
    * @deprecated   replaced by {@code Cursor.HAND_CURSOR}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    public static final int     HAND_CURSOR                     = Cursor.HAND_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
   /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   224
    * @deprecated   replaced by {@code Cursor.MOVE_CURSOR}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    public static final int     MOVE_CURSOR                     = Cursor.MOVE_CURSOR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * Frame is in the "normal" state.  This symbolic constant names a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * frame state with all state bits cleared.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * @see #setExtendedState(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * @see #getExtendedState
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    public static final int NORMAL = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * This state bit indicates that frame is iconified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * @see #setExtendedState(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * @see #getExtendedState
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    public static final int ICONIFIED = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * This state bit indicates that frame is maximized in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * horizontal direction.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * @see #setExtendedState(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * @see #getExtendedState
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public static final int MAXIMIZED_HORIZ = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * This state bit indicates that frame is maximized in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * vertical direction.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * @see #setExtendedState(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * @see #getExtendedState
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    public static final int MAXIMIZED_VERT = 4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * This state bit mask indicates that frame is fully maximized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * (that is both horizontally and vertically).  It is just a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * convenience alias for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * <code>MAXIMIZED_VERT&nbsp;|&nbsp;MAXIMIZED_HORIZ</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * <p>Note that the correct test for frame being fully maximized is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * <pre>
20172
f48935a247ec 8025218: [javadoc] some errors in java/awt classes
yan
parents: 15318
diff changeset
   271
     *     (state &amp; Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * <p>To test is frame is maximized in <em>some</em> direction use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * <pre>
20172
f48935a247ec 8025218: [javadoc] some errors in java/awt classes
yan
parents: 15318
diff changeset
   276
     *     (state &amp; Frame.MAXIMIZED_BOTH) != 0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * @see #setExtendedState(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * @see #getExtendedState
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    public static final int MAXIMIZED_BOTH = MAXIMIZED_VERT | MAXIMIZED_HORIZ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * Maximized bounds for this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @see     #setMaximizedBounds(Rectangle)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * @see     #getMaximizedBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    Rectangle maximizedBounds;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * This is the title of the frame.  It can be changed
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   297
     * at any time.  {@code title} can be null and if
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   298
     * this is the case the {@code title} = "".
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * @see #getTitle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * @see #setTitle(String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    String      title = "Untitled";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   307
     * The frames menubar.  If {@code menuBar} = null
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * the frame will not have a menubar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * @see #getMenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * @see #setMenuBar(MenuBar)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    MenuBar     menuBar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * This field indicates whether the frame is resizable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * This property can be changed at any time.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   319
     * {@code resizable} will be true if the frame is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * resizable, otherwise it will be false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * @see #isResizable()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
    boolean     resizable = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * This field indicates whether the frame is undecorated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * This property can only be changed while the frame is not displayable.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   330
     * {@code undecorated} will be true if the frame is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * undecorated, otherwise it will be false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * @see #setUndecorated(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * @see #isUndecorated()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * @see Component#isDisplayable()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    boolean undecorated = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   342
     * {@code mbManagement} is only used by the Motif implementation.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    boolean     mbManagement = false;   /* used only by the Motif impl. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    // XXX: uwe: abuse old field for now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    // will need to take care of serialization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    private int state = NORMAL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * The Windows owned by the Frame.
26749
b6598aa90114 8055326: Fix typos in client-related packages
serb
parents: 25859
diff changeset
   354
     * Note: in 1.2 this has been superseded by Window.ownedWindowList
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * @see java.awt.Window#ownedWindowList
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     */
15318
607db339afcc 8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents: 12661
diff changeset
   359
    Vector<Window> ownedWindows;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    private static final String base = "frame";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    private static int nameCounter = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     private static final long serialVersionUID = 2673458971256075116L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        /* ensure that the necessary native libraries are loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        Toolkit.loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        if (!GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   378
     * Constructs a new instance of {@code Frame} that is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   379
     * initially invisible.  The title of the {@code Frame}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * is empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * @exception HeadlessException when
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   382
     *     {@code GraphicsEnvironment.isHeadless()} returns {@code true}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * @see java.awt.GraphicsEnvironment#isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * @see Component#setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * @see Component#setVisible(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    public Frame() throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        this("");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * Constructs a new, initially invisible {@code Frame} with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * specified {@code GraphicsConfiguration}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   395
     * @param gc the {@code GraphicsConfiguration}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   396
     * of the target screen device. If {@code gc}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   397
     * is {@code null}, the system default
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   398
     * {@code GraphicsConfiguration} is assumed.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @exception IllegalArgumentException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   400
     * {@code gc} is not from a screen device.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * @exception HeadlessException when
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   402
     *     {@code GraphicsEnvironment.isHeadless()} returns {@code true}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * @see java.awt.GraphicsEnvironment#isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * @since     1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    public Frame(GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        this("", gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   411
     * Constructs a new, initially invisible {@code Frame} object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * with the specified title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @param title the title to be displayed in the frame's border.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   414
     *              A {@code null} value
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     *              is treated as an empty string, "".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @exception HeadlessException when
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   417
     *     {@code GraphicsEnvironment.isHeadless()} returns {@code true}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * @see java.awt.GraphicsEnvironment#isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * @see java.awt.Component#setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * @see java.awt.Component#setVisible(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * @see java.awt.GraphicsConfiguration#getBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    public Frame(String title) throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        init(title, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   428
     * Constructs a new, initially invisible {@code Frame} object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * with the specified title and a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   430
     * {@code GraphicsConfiguration}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * @param title the title to be displayed in the frame's border.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   432
     *              A {@code null} value
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     *              is treated as an empty string, "".
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   434
     * @param gc the {@code GraphicsConfiguration}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   435
     * of the target screen device.  If {@code gc} is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   436
     * {@code null}, the system default
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   437
     * {@code GraphicsConfiguration} is assumed.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   438
     * @exception IllegalArgumentException if {@code gc}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * is not from a screen device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * @exception HeadlessException when
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   441
     *     {@code GraphicsEnvironment.isHeadless()} returns {@code true}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * @see java.awt.GraphicsEnvironment#isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * @see java.awt.Component#setSize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * @see java.awt.Component#setVisible(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * @see java.awt.GraphicsConfiguration#getBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    public Frame(String title, GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        super(gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        init(title, gc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    private void init(String title, GraphicsConfiguration gc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        this.title = title;
12661
6cf8b7116579 7125044: [macosx] Test failure because Component.transferFocus() works differently in applet and application.
ant
parents: 7668
diff changeset
   455
        SunToolkit.checkAndSetPolicy(this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * Construct a name for this component.  Called by getName() when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * name is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    String constructComponentName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        synchronized (Frame.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            return base + nameCounter++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        }
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
     * Makes this Frame displayable by connecting it to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * a native screen resource.  Making a frame displayable will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * cause any of its children to be made displayable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * This method is called internally by the toolkit and should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * not be called directly by programs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * @see Component#isDisplayable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * @see #removeNotify
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    public void addNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            if (peer == null) {
30471
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 26749
diff changeset
   480
                peer = getComponentFactory().createFrame(this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
            FramePeer p = (FramePeer)peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
            MenuBar menuBar = this.menuBar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            if (menuBar != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
                mbManagement = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
                menuBar.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
                p.setMenuBar(menuBar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            p.setMaximizedBounds(maximizedBounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            super.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * Gets the title of the frame.  The title is displayed in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * frame's border.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * @return    the title of this frame, or an empty string ("")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     *                if this frame doesn't have a title.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * @see       #setTitle(String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    public String getTitle() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        return title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * Sets the title for this frame to the specified string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * @param title the title to be displayed in the frame's border.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   508
     *              A {@code null} value
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     *              is treated as an empty string, "".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * @see      #getTitle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    public void setTitle(String title) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        String oldTitle = this.title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        if (title == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            title = "";
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
        synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
            this.title = title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            FramePeer peer = (FramePeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                peer.setTitle(title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        firePropertyChange("title", oldTitle, title);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * Returns the image to be displayed as the icon for this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * This method is obsolete and kept for backward compatibility
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * only. Use {@link Window#getIconImages Window.getIconImages()} instead.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * If a list of several images was specified as a Window's icon,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * this method will return the first item of the list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   538
     * @return    the icon image for this frame, or {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     *                    if this frame doesn't have an icon image.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * @see       #setIconImage(Image)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * @see       Window#getIconImages()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * @see       Window#setIconImages
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    public Image getIconImage() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
        java.util.List<Image> icons = this.icons;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        if (icons != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
            if (icons.size() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
                return icons.get(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    public void setIconImage(Image image) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        super.setIconImage(image);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * Gets the menu bar for this frame.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   563
     * @return    the menu bar for this frame, or {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     *                   if this frame doesn't have a menu bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * @see       #setMenuBar(MenuBar)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    public MenuBar getMenuBar() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        return menuBar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * Sets the menu bar for this frame to the specified menu bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     * @param     mb the menu bar being set.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   574
     *            If this parameter is {@code null} then any
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     *            existing menu bar on this frame is removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * @see       #getMenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    public void setMenuBar(MenuBar mb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
            if (menuBar == mb) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
            if ((mb != null) && (mb.parent != null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
                mb.parent.remove(mb);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            if (menuBar != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                remove(menuBar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            menuBar = mb;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            if (menuBar != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
                menuBar.parent = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
                FramePeer peer = (FramePeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
                if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
                    mbManagement = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
                    menuBar.addNotify();
1183
80d6aafba03a 6682046: Mixing code does not always recalculate shapes correctly when resizing components
anthony
parents: 2
diff changeset
   597
                    invalidateIfValid();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
                    peer.setMenuBar(menuBar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * Indicates whether this frame is resizable by the user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * By default, all frames are initially resizable.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   607
     * @return    {@code true} if the user can resize this frame;
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   608
     *                        {@code false} otherwise.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * @see       java.awt.Frame#setResizable(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    public boolean isResizable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        return resizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     * Sets whether this frame is resizable by the user.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   617
     * @param    resizable   {@code true} if this frame is resizable;
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   618
     *                       {@code false} otherwise.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     * @see      java.awt.Frame#isResizable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    public void setResizable(boolean resizable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        boolean oldResizable = this.resizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        boolean testvalid = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
        synchronized (this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
            this.resizable = resizable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
            FramePeer peer = (FramePeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
                peer.setResizable(resizable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
                testvalid = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        // On some platforms, changing the resizable state affects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        // the insets of the Frame. If we could, we'd call invalidate()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        // from the peer, but we need to guarantee that we're not holding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        // the Frame lock when we call invalidate().
1183
80d6aafba03a 6682046: Mixing code does not always recalculate shapes correctly when resizing components
anthony
parents: 2
diff changeset
   638
        if (testvalid) {
80d6aafba03a 6682046: Mixing code does not always recalculate shapes correctly when resizing components
anthony
parents: 2
diff changeset
   639
            invalidateIfValid();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        firePropertyChange("resizable", oldResizable, resizable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * Sets the state of this frame (obsolete).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * In older versions of JDK a frame state could only be NORMAL or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * ICONIFIED.  Since JDK 1.4 set of supported frame states is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * expanded and frame state is represented as a bitwise mask.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * For compatibility with applications developed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     * earlier this method still accepts
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     * {@code Frame.NORMAL} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * {@code Frame.ICONIFIED} only.  The iconic
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * state of the frame is only changed, other aspects
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * of frame state are not affected by this method. If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * the state passed to this method is neither {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     * Frame.NORMAL} nor {@code Frame.ICONIFIED} the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     * method performs no actions at all.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     * <p>Note that if the state is not supported on a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     * given platform, neither the state nor the return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
     * value of the {@link #getState} method will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * changed. The application may determine whether a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     * specific state is supported via the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     * java.awt.Toolkit#isFrameStateSupported} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * <p><b>If the frame is currently visible on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     * screen</b> (the {@link #isShowing} method returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     * {@code true}), the developer should examine the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     * return value of the  {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     * java.awt.event.WindowEvent#getNewState} method of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     * the {@code WindowEvent} received through the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * {@link java.awt.event.WindowStateListener} to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * determine that the state has actually been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * <p><b>If the frame is not visible on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * screen</b>, the events may or may not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * generated.  In this case the developer may assume
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * that the state changes immediately after this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * method returns.  Later, when the {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * setVisible(true)} method is invoked, the frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * will attempt to apply this state. Receiving any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * java.awt.event.WindowEvent#WINDOW_STATE_CHANGED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * events is not guaranteed in this case also.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   687
     * @param state either {@code Frame.NORMAL} or
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   688
     *     {@code Frame.ICONIFIED}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * @see #setExtendedState(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * @see java.awt.Window#addWindowStateListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    public synchronized void setState(int state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
        int current = getExtendedState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        if (state == ICONIFIED && (current & ICONIFIED) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
            setExtendedState(current | ICONIFIED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        else if (state == NORMAL && (current & ICONIFIED) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
            setExtendedState(current & ~ICONIFIED);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * Sets the state of this frame. The state is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     * represented as a bitwise mask.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * <ul>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   706
     * <li>{@code NORMAL}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * <br>Indicates that no state bits are set.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   708
     * <li>{@code ICONIFIED}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   709
     * <li>{@code MAXIMIZED_HORIZ}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   710
     * <li>{@code MAXIMIZED_VERT}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   711
     * <li>{@code MAXIMIZED_BOTH}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   712
     * <br>Concatenates {@code MAXIMIZED_HORIZ}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   713
     * and {@code MAXIMIZED_VERT}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     * <p>Note that if the state is not supported on a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * given platform, neither the state nor the return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * value of the {@link #getExtendedState} method will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * be changed. The application may determine whether
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * a specific state is supported via the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * java.awt.Toolkit#isFrameStateSupported} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * <p><b>If the frame is currently visible on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * screen</b> (the {@link #isShowing} method returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * {@code true}), the developer should examine the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * return value of the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * java.awt.event.WindowEvent#getNewState} method of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * the {@code WindowEvent} received through the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     * {@link java.awt.event.WindowStateListener} to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * determine that the state has actually been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     * changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * <p><b>If the frame is not visible on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     * screen</b>, the events may or may not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     * generated.  In this case the developer may assume
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     * that the state changes immediately after this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     * method returns.  Later, when the {@code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     * setVisible(true)} method is invoked, the frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
     * will attempt to apply this state. Receiving any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
     * {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     * java.awt.event.WindowEvent#WINDOW_STATE_CHANGED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * events is not guaranteed in this case also.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * @param state a bitwise mask of frame state constants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     * @since   1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     * @see java.awt.Window#addWindowStateListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     */
2453
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   745
    public void setExtendedState(int state) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        if ( !isFrameStateSupported( state ) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        }
2453
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   749
        synchronized (getObjectLock()) {
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   750
            this.state = state;
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   751
        }
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   752
        // peer.setState must be called outside of object lock
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   753
        // synchronization block to avoid possible deadlock
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        FramePeer peer = (FramePeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
            peer.setState(state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
    private boolean isFrameStateSupported(int state) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        if( !getToolkit().isFrameStateSupported( state ) ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
            // * Toolkit.isFrameStateSupported returns always false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
            // on compound state even if all parts are supported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
            // * if part of state is not supported, state is not supported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
            // * MAXIMIZED_BOTH is not a compound state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
            if( ((state & ICONIFIED) != 0) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
                !getToolkit().isFrameStateSupported( ICONIFIED )) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
            }else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
                state &= ~ICONIFIED;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
            return getToolkit().isFrameStateSupported( state );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * Gets the state of this frame (obsolete).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * In older versions of JDK a frame state could only be NORMAL or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     * ICONIFIED.  Since JDK 1.4 set of supported frame states is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * expanded and frame state is represented as a bitwise mask.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     * For compatibility with old programs this method still returns
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   784
     * {@code Frame.NORMAL} and {@code Frame.ICONIFIED} but
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     * it only reports the iconic state of the frame, other aspects of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * frame state are not reported by this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   788
     * @return  {@code Frame.NORMAL} or {@code Frame.ICONIFIED}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     * @see     #setState(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     * @see     #getExtendedState
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    public synchronized int getState() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        return (getExtendedState() & ICONIFIED) != 0 ? ICONIFIED : NORMAL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * Gets the state of this frame. The state is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * represented as a bitwise mask.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     * <ul>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   801
     * <li>{@code NORMAL}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     * <br>Indicates that no state bits are set.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   803
     * <li>{@code ICONIFIED}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   804
     * <li>{@code MAXIMIZED_HORIZ}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   805
     * <li>{@code MAXIMIZED_VERT}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   806
     * <li>{@code MAXIMIZED_BOTH}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   807
     * <br>Concatenates {@code MAXIMIZED_HORIZ}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   808
     * and {@code MAXIMIZED_VERT}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     * </ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
     * @return  a bitwise mask of frame state constants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
     * @see     #setExtendedState(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
     */
2453
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   815
    public int getExtendedState() {
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   816
        synchronized (getObjectLock()) {
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   817
            return state;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
        }
2453
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   819
    }
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   820
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   821
    static {
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   822
        AWTAccessor.setFrameAccessor(
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   823
            new AWTAccessor.FrameAccessor() {
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   824
                public void setExtendedState(Frame frame, int state) {
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   825
                    synchronized(frame.getObjectLock()) {
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   826
                        frame.state = state;
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   827
                    }
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   828
                }
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   829
                public int getExtendedState(Frame frame) {
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   830
                    synchronized(frame.getObjectLock()) {
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   831
                        return frame.state;
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   832
                    }
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   833
                }
7239
514eb274caa1 6699851: setMaximizedbounds not working properly on dual screen environment
dcherepanov
parents: 7236
diff changeset
   834
                public Rectangle getMaximizedBounds(Frame frame) {
514eb274caa1 6699851: setMaximizedbounds not working properly on dual screen environment
dcherepanov
parents: 7236
diff changeset
   835
                    synchronized(frame.getObjectLock()) {
514eb274caa1 6699851: setMaximizedbounds not working properly on dual screen environment
dcherepanov
parents: 7236
diff changeset
   836
                        return frame.maximizedBounds;
514eb274caa1 6699851: setMaximizedbounds not working properly on dual screen environment
dcherepanov
parents: 7236
diff changeset
   837
                    }
514eb274caa1 6699851: setMaximizedbounds not working properly on dual screen environment
dcherepanov
parents: 7236
diff changeset
   838
                }
2453
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   839
            }
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
   840
        );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     * Sets the maximized bounds for this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     * When a frame is in maximized state the system supplies some
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
     * defaults bounds.  This method allows some or all of those
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     * system supplied values to be overridden.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
     * <p>
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   850
     * If {@code bounds} is {@code null}, accept bounds
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   851
     * supplied by the system.  If non-{@code null} you can
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
     * override some of the system supplied values while accepting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
     * others by setting those fields you want to accept from system
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   854
     * to {@code Integer.MAX_VALUE}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
     * <p>
4255
69e00373e85b 6684916: jframe.setMaximizedBounds() has no effect in linux
anthony
parents: 2453
diff changeset
   856
     * Note, the given maximized bounds are used as a hint for the native
69e00373e85b 6684916: jframe.setMaximizedBounds() has no effect in linux
anthony
parents: 2453
diff changeset
   857
     * system, because the underlying platform may not support setting the
69e00373e85b 6684916: jframe.setMaximizedBounds() has no effect in linux
anthony
parents: 2453
diff changeset
   858
     * location and/or size of the maximized windows.  If that is the case, the
69e00373e85b 6684916: jframe.setMaximizedBounds() has no effect in linux
anthony
parents: 2453
diff changeset
   859
     * provided values do not affect the appearance of the frame in the
69e00373e85b 6684916: jframe.setMaximizedBounds() has no effect in linux
anthony
parents: 2453
diff changeset
   860
     * maximized state.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
     * @param bounds  bounds for the maximized state
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
     * @see #getMaximizedBounds()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     */
7239
514eb274caa1 6699851: setMaximizedbounds not working properly on dual screen environment
dcherepanov
parents: 7236
diff changeset
   866
    public void setMaximizedBounds(Rectangle bounds) {
514eb274caa1 6699851: setMaximizedbounds not working properly on dual screen environment
dcherepanov
parents: 7236
diff changeset
   867
        synchronized(getObjectLock()) {
514eb274caa1 6699851: setMaximizedbounds not working properly on dual screen environment
dcherepanov
parents: 7236
diff changeset
   868
            this.maximizedBounds = bounds;
514eb274caa1 6699851: setMaximizedbounds not working properly on dual screen environment
dcherepanov
parents: 7236
diff changeset
   869
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        FramePeer peer = (FramePeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
            peer.setMaximizedBounds(bounds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
     * Gets maximized bounds for this frame.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   878
     * Some fields may contain {@code Integer.MAX_VALUE} to indicate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
     * that system supplied values for this field must be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   881
     * @return  maximized bounds for this frame;  may be {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     * @see     #setMaximizedBounds(Rectangle)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
     * @since   1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    public Rectangle getMaximizedBounds() {
7239
514eb274caa1 6699851: setMaximizedbounds not working properly on dual screen environment
dcherepanov
parents: 7236
diff changeset
   886
        synchronized(getObjectLock()) {
514eb274caa1 6699851: setMaximizedbounds not working properly on dual screen environment
dcherepanov
parents: 7236
diff changeset
   887
            return maximizedBounds;
514eb274caa1 6699851: setMaximizedbounds not working properly on dual screen environment
dcherepanov
parents: 7236
diff changeset
   888
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
     * Disables or enables decorations for this frame.
7236
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   894
     * <p>
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   895
     * This method can only be called while the frame is not displayable. To
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   896
     * make this frame decorated, it must be opaque and have the default shape,
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   897
     * otherwise the {@code IllegalComponentStateException} will be thrown.
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   898
     * Refer to {@link Window#setShape}, {@link Window#setOpacity} and {@link
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   899
     * Window#setBackground} for details
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   900
     *
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   901
     * @param  undecorated {@code true} if no frame decorations are to be
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   902
     *         enabled; {@code false} if frame decorations are to be enabled
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   903
     *
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   904
     * @throws IllegalComponentStateException if the frame is displayable
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   905
     * @throws IllegalComponentStateException if {@code undecorated} is
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   906
     *      {@code false}, and this frame does not have the default shape
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   907
     * @throws IllegalComponentStateException if {@code undecorated} is
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   908
     *      {@code false}, and this frame opacity is less than {@code 1.0f}
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   909
     * @throws IllegalComponentStateException if {@code undecorated} is
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   910
     *      {@code false}, and the alpha value of this frame background
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   911
     *      color is less than {@code 1.0f}
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   912
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
     * @see    #isUndecorated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
     * @see    Component#isDisplayable
7236
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   915
     * @see    Window#getShape
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   916
     * @see    Window#getOpacity
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   917
     * @see    Window#getBackground
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
     * @see    javax.swing.JFrame#setDefaultLookAndFeelDecorated(boolean)
7236
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   919
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
    public void setUndecorated(boolean undecorated) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
        /* Make sure we don't run in the middle of peer creation.*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
            if (isDisplayable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
                throw new IllegalComponentStateException("The frame is displayable.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
            }
7236
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   928
            if (!undecorated) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   929
                if (getOpacity() < 1.0f) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   930
                    throw new IllegalComponentStateException("The frame is not opaque");
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   931
                }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   932
                if (getShape() != null) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   933
                    throw new IllegalComponentStateException("The frame does not have a default shape");
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   934
                }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   935
                Color bg = getBackground();
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   936
                if ((bg != null) && (bg.getAlpha() < 255)) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   937
                    throw new IllegalComponentStateException("The frame background color is not opaque");
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   938
                }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   939
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
            this.undecorated = undecorated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
     * Indicates whether this frame is undecorated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
     * By default, all frames are initially decorated.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   947
     * @return    {@code true} if frame is undecorated;
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   948
     *                        {@code false} otherwise.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     * @see       java.awt.Frame#setUndecorated(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
     * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
    public boolean isUndecorated() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
        return undecorated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
    /**
7236
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   957
     * {@inheritDoc}
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   958
     */
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   959
    @Override
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   960
    public void setOpacity(float opacity) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   961
        synchronized (getTreeLock()) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   962
            if ((opacity < 1.0f) && !isUndecorated()) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   963
                throw new IllegalComponentStateException("The frame is decorated");
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   964
            }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   965
            super.setOpacity(opacity);
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   966
        }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   967
    }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   968
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   969
    /**
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   970
     * {@inheritDoc}
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   971
     */
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   972
    @Override
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   973
    public void setShape(Shape shape) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   974
        synchronized (getTreeLock()) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   975
            if ((shape != null) && !isUndecorated()) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   976
                throw new IllegalComponentStateException("The frame is decorated");
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   977
            }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   978
            super.setShape(shape);
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   979
        }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   980
    }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   981
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   982
    /**
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   983
     * {@inheritDoc}
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   984
     */
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   985
    @Override
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   986
    public void setBackground(Color bgColor) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   987
        synchronized (getTreeLock()) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   988
            if ((bgColor != null) && (bgColor.getAlpha() < 255) && !isUndecorated()) {
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   989
                throw new IllegalComponentStateException("The frame is decorated");
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   990
            }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   991
            super.setBackground(bgColor);
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   992
        }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   993
    }
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   994
e7c280629f58 6993784: Clarification to shaped/translucent windows specification is required
art
parents: 5506
diff changeset
   995
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
     * Removes the specified menu bar from this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
     * @param    m   the menu component to remove.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
   998
     *           If {@code m} is {@code null}, then
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     *           no action is taken
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
    public void remove(MenuComponent m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
        if (m == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
            if (m == menuBar) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
                menuBar = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
                FramePeer peer = (FramePeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
                if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
                    mbManagement = true;
1183
80d6aafba03a 6682046: Mixing code does not always recalculate shapes correctly when resizing components
anthony
parents: 2
diff changeset
  1011
                    invalidateIfValid();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
                    peer.setMenuBar(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
                    m.removeNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
                m.parent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
                super.remove(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     * Makes this Frame undisplayable by removing its connection
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
     * to its native screen resource. Making a Frame undisplayable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
     * will cause any of its children to be made undisplayable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
     * This method is called by the toolkit internally and should
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
     * not be called directly by programs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     * @see Component#isDisplayable
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     * @see #addNotify
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
    public void removeNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
            FramePeer peer = (FramePeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
                // get the latest Frame state before disposing
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
                getState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
                if (menuBar != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
                    mbManagement = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
                    peer.setMenuBar(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
                    menuBar.removeNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
            super.removeNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
    void postProcessKeyEvent(KeyEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
        if (menuBar != null && menuBar.handleShortcut(e)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
            e.consume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
        super.postProcessKeyEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1057
     * Returns a string representing the state of this {@code Frame}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
     * This method is intended to be used only for debugging purposes, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
     * content and format of the returned string may vary between
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
     * implementations. The returned string may be empty but may not be
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1061
     * {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
     * @return the parameter string of this frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
        String str = super.paramString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
        if (title != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
            str += ",title=" + title;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
        if (resizable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
            str += ",resizable";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
        }
2453
35e5fab82613 6724890: Deadlock between AWT-EventQueue-1 and AWT-XAWT threads during IDE start
dcherepanov
parents: 1183
diff changeset
  1073
        int state = getExtendedState();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
        if (state == NORMAL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
            str += ",normal";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
            if ((state & ICONIFIED) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
                str += ",iconified";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
            if ((state & MAXIMIZED_BOTH) == MAXIMIZED_BOTH) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
                str += ",maximized";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
            else if ((state & MAXIMIZED_HORIZ) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
                str += ",maximized_horiz";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
            else if ((state & MAXIMIZED_VERT) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
                str += ",maximized_vert";
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
        return str;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
    /**
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1095
     * Sets the cursor for this frame to the specified type.
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1096
     *
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1097
     * @param  cursorType the cursor type
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
     * @deprecated As of JDK version 1.1,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1099
     * replaced by {@code Component.setCursor(Cursor)}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
    public void setCursor(int cursorType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
        if (cursorType < DEFAULT_CURSOR || cursorType > MOVE_CURSOR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
            throw new IllegalArgumentException("illegal cursor type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
        setCursor(Cursor.getPredefinedCursor(cursorType));
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
     * @deprecated As of JDK version 1.1,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1111
     * replaced by {@code Component.getCursor()}.
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1112
     * @return the cursor type for this frame
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1115
    public int getCursorType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
        return (getCursor().getType());
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
     * Returns an array of all {@code Frame}s created by this application.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
     * If called from an applet, the array includes only the {@code Frame}s
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
     * accessible by that applet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
     * <b>Warning:</b> this method may return system created frames, such
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
     * as a shared, hidden frame which is used by Swing. Applications
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
     * should not assume the existence of these frames, nor should an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
     * application assume anything about these frames such as component
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1128
     * positions, {@code LayoutManager}s or serialization.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
     * <b>Note</b>: To obtain a list of all ownerless windows, including
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
     * ownerless {@code Dialog}s (introduced in release 1.6), use {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
     * Window#getOwnerlessWindows Window.getOwnerlessWindows}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
     *
25162
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1134
     * @return the array of all {@code Frame}s created by this application
c388078278d4 8043967: Fix doclint warnings for java.awt
yan
parents: 24865
diff changeset
  1135
     *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
     * @see Window#getWindows()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
     * @see Window#getOwnerlessWindows
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
    public static Frame[] getFrames() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1142
        Window[] allWindows = Window.getWindows();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
        int frameCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
        for (Window w : allWindows) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
            if (w instanceof Frame) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
                frameCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
        Frame[] frames = new Frame[frameCount];
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
        int c = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
        for (Window w : allWindows) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
            if (w instanceof Frame) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
                frames[c++] = (Frame)w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
        return frames;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1162
    /* Serialization support.  If there's a MenuBar we restore
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
     * its (transient) parent field here.  Likewise for top level
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
     * windows that are "owned" by this frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1168
     * {@code Frame}'s Serialized Data Version.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
    private int frameSerializedDataVersion = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
     * Writes default serializable fields to stream.  Writes
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1176
     * an optional serializable icon {@code Image}, which is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
     * available as of 1.4.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1179
     * @param s the {@code ObjectOutputStream} to write
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1180
     * @serialData an optional icon {@code Image}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
     * @see java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
     * @see #getIconImage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
     * @see #setIconImage(Image)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
     * @see #readObject(ObjectInputStream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
    private void writeObject(ObjectOutputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
      throws IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
        s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
        if (icons != null && icons.size() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
            Image icon1 = icons.get(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
            if (icon1 instanceof Serializable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
                s.writeObject(icon1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
        s.writeObject(null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1200
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1201
     * Reads the {@code ObjectInputStream}.  Tries
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1202
     * to read an icon {@code Image}, which is optional
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1203
     * data available as of 1.4.  If an icon {@code Image}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
     * is not available, but anything other than an EOF
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1205
     * is detected, an {@code OptionalDataException}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
     * will be thrown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
     * Unrecognized keys or values will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1209
     * @param s the {@code ObjectInputStream} to read
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1210
     * @exception java.io.OptionalDataException if an icon {@code Image}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
     *   is not available, but anything other than an EOF
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
     *   is detected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
     * @exception HeadlessException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1214
     *   {@code GraphicsEnvironment.isHeadless} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1215
     *   {@code true}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
     * @see java.awt.GraphicsEnvironment#isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
     * @see java.awt.Image
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
     * @see #getIconImage
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
     * @see #setIconImage(Image)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
     * @see #writeObject(ObjectOutputStream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
      throws ClassNotFoundException, IOException, HeadlessException
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
      // HeadlessException is thrown by Window's readObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
      s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
      try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1228
          Image icon = (Image) s.readObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
          if (icons == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
              icons = new ArrayList<Image>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
              icons.add(icon);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
      } catch (java.io.OptionalDataException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
          // pre-1.4 instances will not have this optional data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
          // 1.6 and later instances serialize icons in the Window class
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
          // e.eof will be true to indicate that there is no more
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
          // data available for this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
          // If e.eof is not true, throw the exception as it
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
          // might have been caused by unrelated reasons.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
          if (!e.eof) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1242
              throw (e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
      if (menuBar != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
        menuBar.parent = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
      // Ensure 1.1 serialized Frames can read & hook-up
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
      // owned windows properly
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
      //
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
      if (ownedWindows != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
          for (int i = 0; i < ownedWindows.size(); i++) {
15318
607db339afcc 8005492: Reduce number of warnings in sun/awt/* classes
mcherkas
parents: 12661
diff changeset
  1254
              connectOwnedWindow(ownedWindows.elementAt(i));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
          ownedWindows = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
     * Initialize JNI field and method IDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
     * --- Accessibility Support ---
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
     * Gets the AccessibleContext associated with this Frame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
     * For frames, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
     * AccessibleAWTFrame.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
     * A new AccessibleAWTFrame instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
     * @return an AccessibleAWTFrame that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
     *         AccessibleContext of this Frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
            accessibleContext = new AccessibleAWTFrame();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
     * This class implements accessibility support for the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 30471
diff changeset
  1289
     * {@code Frame} class.  It provides an implementation of the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
     * Java Accessibility API appropriate to frame user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
    protected class AccessibleAWTFrame extends AccessibleAWTWindow
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
         * JDK 1.3 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
        private static final long serialVersionUID = -6172960752956030250L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1302
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
         * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
         * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
         * @see AccessibleRole
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
            return AccessibleRole.FRAME;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
         * Get the state of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
         * @return an instance of AccessibleStateSet containing the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
         * state set of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
         * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1317
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
        public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
            AccessibleStateSet states = super.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
            if (getFocusOwner() != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
                states.add(AccessibleState.ACTIVE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
            if (isResizable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
                states.add(AccessibleState.RESIZABLE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
            return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1329
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
    } // inner class AccessibleAWTFrame
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
}