jdk/src/share/classes/sun/awt/EmbeddedFrame.java
author dxu
Thu, 04 Apr 2013 15:39:17 -0700
changeset 16734 da1901d79073
parent 15983 26a673dec5b2
child 16901 d98c53659845
permissions -rw-r--r--
8000406: change files using @GenerateNativeHeader to use @Native Summary: Use @Native annotation to mark constants interested by native codes Reviewed-by: alanb, anthony, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
16734
da1901d79073 8000406: change files using @GenerateNativeHeader to use @Native
dxu
parents: 15983
diff changeset
     2
 * Copyright (c) 1996, 2013, 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: 2808
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: 2808
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: 2808
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2808
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2808
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.event.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.image.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.peer.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.beans.PropertyChangeListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.beans.PropertyChangeEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.util.Set;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.AWTKeyStroke;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.applet.Applet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.applet.AppletPanel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * A generic container used for embedding Java components, usually applets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * An EmbeddedFrame has two related uses:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * . Within a Java-based application, an EmbeddedFrame serves as a sort of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *   firewall, preventing the contained components or applets from using
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *   getParent() to find parent components, such as menubars.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * . Within a C-based application, an EmbeddedFrame contains a window handle
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *   which was created by the application, which serves as the top-level
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *   Java window.  EmbeddedFrames created for this purpose are passed-in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *   handle of an existing window created by the application.  The window
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *   handle should be of the appropriate native type for a specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *   platform, as stored in the pData field of the ComponentPeer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * @author      Thomas Ball
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
public abstract class EmbeddedFrame extends Frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
                          implements KeyEventDispatcher, PropertyChangeListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private boolean isCursorAllowed = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private boolean supportsXEmbed = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private KeyboardFocusManager appletKFM;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    // JDK 1.1 compatibility
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private static final long serialVersionUID = 2967042741780317130L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
6634
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
    65
    /*
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
    66
     * The constants define focus traversal directions.
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
    67
     * Use them in {@code traverseIn}, {@code traverseOut} methods.
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
    68
     */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    protected static final boolean FORWARD = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    protected static final boolean BACKWARD = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public boolean supportsXEmbed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        return supportsXEmbed && SunToolkit.needsXEmbed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    protected EmbeddedFrame(boolean supportsXEmbed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        this((long)0, supportsXEmbed);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    protected EmbeddedFrame() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        this((long)0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * @deprecated This constructor will be removed in 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    protected EmbeddedFrame(int handle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        this((long)handle);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    protected EmbeddedFrame(long handle) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        this(handle, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    protected EmbeddedFrame(long handle, boolean supportsXEmbed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        this.supportsXEmbed = supportsXEmbed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        registerListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * Block introspection of a parent window by this child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    public Container getParent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * Needed to track which KeyboardFocusManager is current. We want to avoid memory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * leaks, so when KFM stops being current, we remove ourselves as listeners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    public void propertyChange(PropertyChangeEvent evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        // We don't handle any other properties. Skip it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        if (!evt.getPropertyName().equals("managingFocus")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        // We only do it if it stops being current. Technically, we should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        // never get an event about KFM starting being current.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        if (evt.getNewValue() == Boolean.TRUE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        // should be the same as appletKFM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        removeTraversingOutListeners((KeyboardFocusManager)evt.getSource());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        appletKFM = KeyboardFocusManager.getCurrentKeyboardFocusManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        if (isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            addTraversingOutListeners(appletKFM);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Register us as KeyEventDispatcher and property "managingFocus" listeners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    private void addTraversingOutListeners(KeyboardFocusManager kfm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        kfm.addKeyEventDispatcher(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        kfm.addPropertyChangeListener("managingFocus", this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * Deregister us as KeyEventDispatcher and property "managingFocus" listeners.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    private void removeTraversingOutListeners(KeyboardFocusManager kfm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        kfm.removeKeyEventDispatcher(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        kfm.removePropertyChangeListener("managingFocus", this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * Because there may be many AppContexts, and we can't be sure where this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * EmbeddedFrame is first created or shown, we can't automatically determine
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * the correct KeyboardFocusManager to attach to as KeyEventDispatcher.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * Those who want to use the functionality of traversing out of the EmbeddedFrame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * must call this method on the Applet's AppContext. After that, all the changes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * can be handled automatically, including possible replacement of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * KeyboardFocusManager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    public void registerListeners() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        if (appletKFM != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            removeTraversingOutListeners(appletKFM);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        appletKFM = KeyboardFocusManager.getCurrentKeyboardFocusManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        if (isVisible()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            addTraversingOutListeners(appletKFM);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * Needed to avoid memory leak: we register this EmbeddedFrame as a listener with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * KeyboardFocusManager of applet's AppContext. We don't want the KFM to keep
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * reference to our EmbeddedFrame forever if the Frame is no longer in use, so we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * add listeners in show() and remove them in hide().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     */
11264
54f2f4c6bd30 7117008: Warnings cleanup day: reduce number of javac warnings in the sun.awt package
art
parents: 7668
diff changeset
   175
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    public void show() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        if (appletKFM != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            addTraversingOutListeners(appletKFM);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        super.show();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * Needed to avoid memory leak: we register this EmbeddedFrame as a listener with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * KeyboardFocusManager of applet's AppContext. We don't want the KFM to keep
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * reference to our EmbeddedFrame forever if the Frame is no longer in use, so we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * add listeners in show() and remove them in hide().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     */
11264
54f2f4c6bd30 7117008: Warnings cleanup day: reduce number of javac warnings in the sun.awt package
art
parents: 7668
diff changeset
   189
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public void hide() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        if (appletKFM != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            removeTraversingOutListeners(appletKFM);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        super.hide();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * Need this method to detect when the focus may have chance to leave the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * focus cycle root which is EmbeddedFrame. Mostly, the code here is copied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * from DefaultKeyboardFocusManager.processKeyEvent with some minor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * modifications.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    public boolean dispatchKeyEvent(KeyEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
13604
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 12813
diff changeset
   205
        Container currentRoot = AWTAccessor.getKeyboardFocusManagerAccessor()
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 12813
diff changeset
   206
                                    .getCurrentFocusCycleRoot();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        // if we are not in EmbeddedFrame's cycle, we should not try to leave.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        if (this != currentRoot) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        // KEY_TYPED events cannot be focus traversal keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        if (e.getID() == KeyEvent.KEY_TYPED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        if (!getFocusTraversalKeysEnabled() || e.isConsumed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        AWTKeyStroke stroke = AWTKeyStroke.getAWTKeyStrokeForEvent(e);
11264
54f2f4c6bd30 7117008: Warnings cleanup day: reduce number of javac warnings in the sun.awt package
art
parents: 7668
diff changeset
   223
        Set<AWTKeyStroke> toTest;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        Component currentFocused = e.getComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        toTest = getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
1179
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   227
        if (toTest.contains(stroke)) {
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   228
            // 6581899: performance improvement for SortingFocusTraversalPolicy
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   229
            Component last = getFocusTraversalPolicy().getLastComponent(this);
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   230
            if (currentFocused == last || last == null) {
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   231
                if (traverseOut(FORWARD)) {
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   232
                    e.consume();
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   233
                    return true;
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   234
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        toTest = getFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS);
1179
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   239
        if (toTest.contains(stroke)) {
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   240
            // 6581899: performance improvement for SortingFocusTraversalPolicy
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   241
            Component first = getFocusTraversalPolicy().getFirstComponent(this);
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   242
            if (currentFocused == first || first == null) {
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   243
                if (traverseOut(BACKWARD)) {
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   244
                    e.consume();
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   245
                    return true;
b0d106998757 6581899: JTextField & JTextArea - Poor performance with JRE 1.5.0_08
dcherepanov
parents: 2
diff changeset
   246
                }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    /**
6634
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   253
     * This method is called by the embedder when we should receive focus as element
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   254
     * of the traversal chain.  The method requests focus on:
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   255
     * 1. the first Component of this EmbeddedFrame if user moves focus forward
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   256
     *    in the focus traversal cycle.
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   257
     * 2. the last Component of this EmbeddedFrame if user moves focus backward
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   258
     *    in the focus traversal cycle.
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   259
     *
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   260
     * The direction parameter specifies which of the two mentioned cases is
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   261
     * happening. Use FORWARD and BACKWARD constants defined in the EmbeddedFrame class
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   262
     * to avoid confusing boolean values.
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   263
     *
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   264
     * A concrete implementation of this method is defined in the platform-dependent
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   265
     * subclasses.
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   266
     *
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   267
     * @param direction FORWARD or BACKWARD
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   268
     * @return true, if the EmbeddedFrame wants to get focus, false otherwise.
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   269
     */
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   270
    public boolean traverseIn(boolean direction) {
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   271
        Component comp = null;
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   272
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   273
        if (direction == FORWARD) {
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   274
            comp = getFocusTraversalPolicy().getFirstComponent(this);
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   275
        } else {
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   276
            comp = getFocusTraversalPolicy().getLastComponent(this);
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   277
        }
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   278
        if (comp != null) {
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   279
            // comp.requestFocus(); - Leads to a hung.
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   280
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   281
            AWTAccessor.getKeyboardFocusManagerAccessor().setMostRecentFocusOwner(this, comp);
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   282
            synthesizeWindowActivation(true);
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   283
        }
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   284
        return (null != comp);
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   285
    }
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   286
439221465ac5 6505819: Provide traverseIn method for sun.awt.EmbeddedFrame
ant
parents: 5506
diff changeset
   287
    /**
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * This method is called from dispatchKeyEvent in the following two cases:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * 1. The focus is on the first Component of this EmbeddedFrame and we are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *    about to transfer the focus backward.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * 2. The focus in on the last Component of this EmbeddedFrame and we are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     *    about to transfer the focus forward.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * This is needed to give the opportuity for keyboard focus to leave the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * EmbeddedFrame. Override this method, initiate focus transfer in it and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * return true if you want the focus to leave EmbeddedFrame's cycle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * The direction parameter specifies which of the two mentioned cases is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * happening. Use FORWARD and BACKWARD constants defined in EmbeddedFrame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * to avoid confusing boolean values.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * @param direction FORWARD or BACKWARD
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * @return true, if EmbeddedFrame wants the focus to leave it,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     *         false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    protected boolean traverseOut(boolean direction) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * Block modifying any frame attributes, since they aren't applicable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * for EmbeddedFrames.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    public void setTitle(String title) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    public void setIconImage(Image image) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
    public void setIconImages(java.util.List<? extends Image> icons) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
    public void setMenuBar(MenuBar mb) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    public void setResizable(boolean resizable) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    public void remove(MenuComponent m) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    public boolean isResizable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
11264
54f2f4c6bd30 7117008: Warnings cleanup day: reduce number of javac warnings in the sun.awt package
art
parents: 7668
diff changeset
   323
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    public void addNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            if (getPeer() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                setPeer(new NullEmbeddedFramePeer());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            super.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    // These three functions consitute RFE 4100710. Do not remove.
11264
54f2f4c6bd30 7117008: Warnings cleanup day: reduce number of javac warnings in the sun.awt package
art
parents: 7668
diff changeset
   334
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    public void setCursorAllowed(boolean isCursorAllowed) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        this.isCursorAllowed = isCursorAllowed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        getPeer().updateCursorImmediately();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    public boolean isCursorAllowed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        return isCursorAllowed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    public Cursor getCursor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        return (isCursorAllowed)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            ? super.getCursor()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            : Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
11264
54f2f4c6bd30 7117008: Warnings cleanup day: reduce number of javac warnings in the sun.awt package
art
parents: 7668
diff changeset
   348
    @SuppressWarnings("deprecation")
54f2f4c6bd30 7117008: Warnings cleanup day: reduce number of javac warnings in the sun.awt package
art
parents: 7668
diff changeset
   349
    protected void setPeer(final ComponentPeer p){
13604
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 12813
diff changeset
   350
        AWTAccessor.getComponentAccessor().setPeer(EmbeddedFrame.this, p);
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 12813
diff changeset
   351
    };
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * Synthesize native message to activate or deactivate EmbeddedFrame window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * depending on the value of parameter <code>b</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * Peers should override this method if they are to implement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * this functionality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * @param doActivate  if <code>true</code>, activates the window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * otherwise, deactivates the window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    public void synthesizeWindowActivation(boolean doActivate) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * Moves this embedded frame to a new location. The top-left corner of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     * the new location is specified by the <code>x</code> and <code>y</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * parameters relative to the native parent component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * setLocation() and setBounds() for EmbeddedFrame really don't move it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * within the native parent. These methods always put embedded frame to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * (0, 0) for backward compatibility. To allow moving embedded frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     * setLocationPrivate() and setBoundsPrivate() were introduced, and they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * work just the same way as setLocation() and setBounds() for usual,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * non-embedded components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * Using usual get/setLocation() and get/setBounds() together with new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * get/setLocationPrivate() and get/setBoundsPrivate() is not recommended.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * For example, calling getBoundsPrivate() after setLocation() works fine,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * but getBounds() after setBoundsPrivate() may return unpredictable value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * @param x the new <i>x</i>-coordinate relative to the parent component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * @param y the new <i>y</i>-coordinate relative to the parent component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * @see java.awt.Component#setLocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * @see #getLocationPrivate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * @see #setBoundsPrivate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * @see #getBoundsPrivate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    protected void setLocationPrivate(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        Dimension size = getSize();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        setBoundsPrivate(x, y, size.width, size.height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * Gets the location of this embedded frame as a point specifying the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * top-left corner relative to parent component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * setLocation() and setBounds() for EmbeddedFrame really don't move it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * within the native parent. These methods always put embedded frame to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * (0, 0) for backward compatibility. To allow getting location and size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * of embedded frame getLocationPrivate() and getBoundsPrivate() were
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * introduced, and they work just the same way as getLocation() and getBounds()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * for ususal, non-embedded components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * Using usual get/setLocation() and get/setBounds() together with new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * get/setLocationPrivate() and get/setBoundsPrivate() is not recommended.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * For example, calling getBoundsPrivate() after setLocation() works fine,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * but getBounds() after setBoundsPrivate() may return unpredictable value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * @return a point indicating this embedded frame's top-left corner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * @see java.awt.Component#getLocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @see #setLocationPrivate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * @see #setBoundsPrivate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @see #getBoundsPrivate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    protected Point getLocationPrivate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        Rectangle bounds = getBoundsPrivate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        return new Point(bounds.x, bounds.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * Moves and resizes this embedded frame. The new location of the top-left
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     * corner is specified by <code>x</code> and <code>y</code> parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * relative to the native parent component. The new size is specified by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * <code>width</code> and <code>height</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * setLocation() and setBounds() for EmbeddedFrame really don't move it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * within the native parent. These methods always put embedded frame to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * (0, 0) for backward compatibility. To allow moving embedded frames
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * setLocationPrivate() and setBoundsPrivate() were introduced, and they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     * work just the same way as setLocation() and setBounds() for usual,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * non-embedded components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * Using usual get/setLocation() and get/setBounds() together with new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * get/setLocationPrivate() and get/setBoundsPrivate() is not recommended.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * For example, calling getBoundsPrivate() after setLocation() works fine,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * but getBounds() after setBoundsPrivate() may return unpredictable value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * @param x the new <i>x</i>-coordinate relative to the parent component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * @param y the new <i>y</i>-coordinate relative to the parent component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * @param width the new <code>width</code> of this embedded frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * @param height the new <code>height</code> of this embedded frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * @see java.awt.Component#setBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * @see #setLocationPrivate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * @see #getLocationPrivate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * @see #getBoundsPrivate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * @since 1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     */
11264
54f2f4c6bd30 7117008: Warnings cleanup day: reduce number of javac warnings in the sun.awt package
art
parents: 7668
diff changeset
   452
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    protected void setBoundsPrivate(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        final FramePeer peer = (FramePeer)getPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            peer.setBoundsPrivate(x, y, width, height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * Gets the bounds of this embedded frame as a rectangle specifying the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * width, height and location relative to the native parent component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * setLocation() and setBounds() for EmbeddedFrame really don't move it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * within the native parent. These methods always put embedded frame to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * (0, 0) for backward compatibility. To allow getting location and size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * of embedded frames getLocationPrivate() and getBoundsPrivate() were
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * introduced, and they work just the same way as getLocation() and getBounds()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * for ususal, non-embedded components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * Using usual get/setLocation() and get/setBounds() together with new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * get/setLocationPrivate() and get/setBoundsPrivate() is not recommended.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * For example, calling getBoundsPrivate() after setLocation() works fine,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * but getBounds() after setBoundsPrivate() may return unpredictable value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * </p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * @return a rectangle indicating this embedded frame's bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * @see java.awt.Component#getBounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     * @see #setLocationPrivate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * @see #getLocationPrivate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * @see #setBoundsPrivate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     */
11264
54f2f4c6bd30 7117008: Warnings cleanup day: reduce number of javac warnings in the sun.awt package
art
parents: 7668
diff changeset
   484
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    protected Rectangle getBoundsPrivate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        final FramePeer peer = (FramePeer)getPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            return peer.getBoundsPrivate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
            return getBounds();
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
    public void toFront() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    public void toBack() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    public abstract void registerAccelerator(AWTKeyStroke stroke);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    public abstract void unregisterAccelerator(AWTKeyStroke stroke);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * Checks if the component is in an EmbeddedFrame. If so,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * returns the applet found in the hierarchy or null if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * not found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * @return the parent applet or {@ null}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    public static Applet getAppletIfAncestorOf(Component comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        Container parent = comp.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        Applet applet = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        while (parent != null && !(parent instanceof EmbeddedFrame)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
            if (parent instanceof Applet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
                applet = (Applet)parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            parent = parent.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        return parent == null ? null : applet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
     * This method should be overriden in subclasses. It is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
     * called when window this frame is within should be blocked
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * by some modal dialog.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    public void notifyModalBlocked(Dialog blocker, boolean blocked) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    private static class NullEmbeddedFramePeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        extends NullComponentPeer implements FramePeer {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        public void setTitle(String title) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        public void setIconImage(Image im) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        public void updateIconImages() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        public void setMenuBar(MenuBar mb) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        public void setResizable(boolean resizeable) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        public void setState(int state) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        public int getState() { return Frame.NORMAL; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        public void setMaximizedBounds(Rectangle b) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
        public void toFront() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        public void toBack() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        public void updateFocusableWindowState() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        public void updateAlwaysOnTop() {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
        public void setAlwaysOnTop(boolean alwaysOnTop) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        public Component getGlobalHeavyweightFocusOwner() { return null; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
        public void setBoundsPrivate(int x, int y, int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
            setBounds(x, y, width, height, SET_BOUNDS);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        public Rectangle getBoundsPrivate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            return getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        public void setModalBlocked(Dialog blocker, boolean blocked) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
         * @see java.awt.peer.ContainerPeer#restack
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
        public void restack() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
         * @see java.awt.peer.ContainerPeer#isRestackSupported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        public boolean isRestackSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        public boolean requestWindowFocus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        public void updateMinimumSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        }
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1179
diff changeset
   570
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1179
diff changeset
   571
        public void setOpacity(float opacity) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1179
diff changeset
   572
        }
2648
aa45a227fce3 6802853: API: shaped & translucent windows
anthony
parents: 2472
diff changeset
   573
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1179
diff changeset
   574
        public void setOpaque(boolean isOpaque) {
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1179
diff changeset
   575
        }
2648
aa45a227fce3 6802853: API: shaped & translucent windows
anthony
parents: 2472
diff changeset
   576
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2648
diff changeset
   577
        public void updateWindow() {
2451
597df8e1d786 6633275: Need to support shaped/translucent windows
art
parents: 1179
diff changeset
   578
        }
2808
a139a919f645 6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents: 2648
diff changeset
   579
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2451
diff changeset
   580
        public void repositionSecurityWarning() {
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2451
diff changeset
   581
        }
15983
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 13604
diff changeset
   582
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 13604
diff changeset
   583
        public void emulateActivation(boolean activate) {
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 13604
diff changeset
   584
        }
26a673dec5b2 8006406: lightweight embedding in other Java UI toolkits
ant
parents: 13604
diff changeset
   585
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
} // class EmbeddedFrame