src/java.desktop/share/classes/java/awt/MenuComponent.java
author darcy
Tue, 24 Sep 2019 18:25:54 -0700
changeset 58309 c6f8b2c3dc66
parent 47216 71c04702a3d5
permissions -rw-r--r--
8231334: Suppress warnings on non-serializable instance fields in client libs serializable classes Reviewed-by: prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
42740
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
     2
 * Copyright (c) 1995, 2016, 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: 3084
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: 3084
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: 3084
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3084
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3084
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
42740
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    25
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
42740
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    28
import java.awt.event.ActionEvent;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.peer.MenuComponentPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.io.ObjectInputStream;
8816
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
    32
import java.security.AccessControlContext;
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
    33
import java.security.AccessController;
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
    34
42740
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    35
import javax.accessibility.Accessible;
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    36
import javax.accessibility.AccessibleComponent;
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    37
import javax.accessibility.AccessibleContext;
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    38
import javax.accessibility.AccessibleRole;
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    39
import javax.accessibility.AccessibleSelection;
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    40
import javax.accessibility.AccessibleState;
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    41
import javax.accessibility.AccessibleStateSet;
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    42
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    43
import sun.awt.AWTAccessor;
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    44
import sun.awt.AppContext;
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    45
import sun.awt.ComponentFactory;
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    46
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
/**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    48
 * The abstract class {@code MenuComponent} is the superclass
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * of all menu-related components. In this respect, the class
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    50
 * {@code MenuComponent} is analogous to the abstract superclass
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    51
 * {@code Component} for AWT components.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * Menu components receive and process AWT events, just as components do,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    54
 * through the method {@code processEvent}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * @author      Arthur van Hoff
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
    57
 * @since       1.0
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
public abstract class MenuComponent implements java.io.Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
        /* ensure that the necessary native libraries are loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        Toolkit.loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        if (!GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
            initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
30469
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 29886
diff changeset
    69
    transient volatile MenuComponentPeer peer;
42740
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    70
    transient volatile MenuContainer parent;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    73
     * The {@code AppContext} of the {@code MenuComponent}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * This is set in the constructor and never changes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
42740
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    76
    private transient volatile AppContext appContext;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * The menu component's font. This value can be
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    80
     * {@code null} at which point a default will be used.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    81
     * This defaults to {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @see #setFont(Font)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * @see #getFont()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     */
42740
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    87
    private volatile Font font;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    90
     * The menu component's name, which defaults to {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * @see #getName()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * @see #setName(String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
42740
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
    95
    private volatile String name;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * A variable to indicate whether a name is explicitly set.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
    99
     * If {@code true} the name will be set explicitly.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   100
     * This defaults to {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * @see #setName(String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
42740
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
   104
    private volatile boolean nameExplicitlySet;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   107
     * Defaults to {@code false}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * @see #dispatchEvent(AWTEvent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     */
42740
ad57210989cd 8165769: Hang in the help menu item
serb
parents: 35667
diff changeset
   111
    volatile boolean newEventsOnly;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /*
8816
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   114
     * The menu's AccessControlContext.
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   115
     */
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   116
    private transient volatile AccessControlContext acc =
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   117
            AccessController.getContext();
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   118
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   119
    /*
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   120
     * Returns the acc this menu component was constructed with.
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   121
     */
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   122
    final AccessControlContext getAccessControlContext() {
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   123
        if (acc == null) {
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   124
            throw new SecurityException(
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   125
                    "MenuComponent is missing AccessControlContext");
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   126
        }
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   127
        return acc;
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   128
    }
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   129
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   130
    /*
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * Internal constants for serialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     */
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 30918
diff changeset
   133
    static final String actionListenerK = Component.actionListenerK;
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 30918
diff changeset
   134
    static final String itemListenerK = Component.itemListenerK;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    private static final long serialVersionUID = -4536902356223894379L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
3084
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   141
    static {
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   142
        AWTAccessor.setMenuComponentAccessor(
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   143
            new AWTAccessor.MenuComponentAccessor() {
25764
6333e4aa8a70 8049830: Remove reflection from ScreenMenuBar
pchelko
parents: 25162
diff changeset
   144
                @Override
3084
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   145
                public AppContext getAppContext(MenuComponent menuComp) {
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   146
                    return menuComp.appContext;
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   147
                }
25764
6333e4aa8a70 8049830: Remove reflection from ScreenMenuBar
pchelko
parents: 25162
diff changeset
   148
                @Override
3084
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   149
                public void setAppContext(MenuComponent menuComp,
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   150
                                          AppContext appContext) {
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   151
                    menuComp.appContext = appContext;
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   152
                }
25764
6333e4aa8a70 8049830: Remove reflection from ScreenMenuBar
pchelko
parents: 25162
diff changeset
   153
                @Override
30469
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 29886
diff changeset
   154
                @SuppressWarnings("unchecked")
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 29886
diff changeset
   155
                public <T extends MenuComponentPeer> T getPeer(MenuComponent menuComp) {
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 29886
diff changeset
   156
                    return (T) menuComp.peer;
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 29886
diff changeset
   157
                }
bac0a7ff7e1e 8074028: Remove API references to java.awt.peer
serb
parents: 29886
diff changeset
   158
                @Override
3084
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   159
                public MenuContainer getParent(MenuComponent menuComp) {
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   160
                    return menuComp.parent;
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   161
                }
25764
6333e4aa8a70 8049830: Remove reflection from ScreenMenuBar
pchelko
parents: 25162
diff changeset
   162
                @Override
6333e4aa8a70 8049830: Remove reflection from ScreenMenuBar
pchelko
parents: 25162
diff changeset
   163
                public void setParent(MenuComponent menuComp, MenuContainer menuContainer) {
6333e4aa8a70 8049830: Remove reflection from ScreenMenuBar
pchelko
parents: 25162
diff changeset
   164
                    menuComp.parent = menuContainer;
6333e4aa8a70 8049830: Remove reflection from ScreenMenuBar
pchelko
parents: 25162
diff changeset
   165
                }
6333e4aa8a70 8049830: Remove reflection from ScreenMenuBar
pchelko
parents: 25162
diff changeset
   166
                @Override
13604
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 9035
diff changeset
   167
                public Font getFont_NoClientCode(MenuComponent menuComp) {
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 9035
diff changeset
   168
                    return menuComp.getFont_NoClientCode();
31089af1a447 7163201: Simplify toolkit internals references
bagiras
parents: 9035
diff changeset
   169
                }
3084
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   170
            });
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   171
    }
67ca55732362 6824169: Need to remove some AWT class dependencies
dcherepanov
parents: 2
diff changeset
   172
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   174
     * Creates a {@code MenuComponent}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @exception HeadlessException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   176
     *    {@code GraphicsEnvironment.isHeadless}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   177
     *    returns {@code true}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    public MenuComponent() throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        GraphicsEnvironment.checkHeadless();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        appContext = AppContext.getAppContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   186
     * Constructs a name for this {@code MenuComponent}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   187
     * Called by {@code getName} when the name is {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   188
     * @return a name for this {@code MenuComponent}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    String constructComponentName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        return null; // For strict compliance with prior platform versions, a MenuComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                     // that doesn't set its name should return null from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                     // getName()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
30471
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 30469
diff changeset
   196
    final ComponentFactory getComponentFactory() {
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 30469
diff changeset
   197
        final Toolkit toolkit = Toolkit.getDefaultToolkit();
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 30469
diff changeset
   198
        if (toolkit instanceof ComponentFactory) {
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 30469
diff changeset
   199
            return (ComponentFactory) toolkit;
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 30469
diff changeset
   200
        }
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 30469
diff changeset
   201
        throw new AWTError("UI components are unsupported by: " + toolkit);
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 30469
diff changeset
   202
    }
c1568a2416a8 8074757: Remove java.awt.Toolkit methods which return peer types
serb
parents: 30469
diff changeset
   203
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * Gets the name of the menu component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @return        the name of the menu component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @see           java.awt.MenuComponent#setName(java.lang.String)
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   208
     * @since         1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    public String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        if (name == null && !nameExplicitlySet) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                if (name == null && !nameExplicitlySet)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                    name = constructComponentName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        return name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * Sets the name of the component to the specified string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * @param         name    the name of the menu component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * @see           java.awt.MenuComponent#getName
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   224
     * @since         1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    public void setName(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        synchronized(this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            this.name = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            nameExplicitlySet = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * Returns the parent container for this menu component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * @return    the menu component containing this menu component,
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   236
     *                 or {@code null} if this menu component
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     *                 is the outermost component, the menu bar itself
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    public MenuContainer getParent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        return getParent_NoClientCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    // NOTE: This method may be called by privileged threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    //       This functionality is implemented in a package-private method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    //       to insure that it cannot be overridden by client subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    final MenuContainer getParent_NoClientCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        return parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * Gets the font used for this menu component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * @return   the font used in this menu component, if there is one;
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   253
     *                  {@code null} otherwise
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @see     java.awt.MenuComponent#setFont
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    public Font getFont() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        Font font = this.font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        if (font != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            return font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        MenuContainer parent = this.parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        if (parent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            return parent.getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    // NOTE: This method may be called by privileged threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    //       This functionality is implemented in a package-private method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    //       to insure that it cannot be overridden by client subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    //       DO NOT INVOKE CLIENT CODE ON THIS THREAD!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    final Font getFont_NoClientCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        Font font = this.font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        if (font != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            return font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        // The MenuContainer interface does not have getFont_NoClientCode()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        // and it cannot, because it must be package-private. Because of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        // this, we must manually cast classes that implement
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        // MenuContainer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        Object parent = this.parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        if (parent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            if (parent instanceof Component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                font = ((Component)parent).getFont_NoClientCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            } else if (parent instanceof MenuComponent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                font = ((MenuComponent)parent).getFont_NoClientCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        return font;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    } // getFont_NoClientCode()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * Sets the font to be used for this menu component to the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * font. This font is also used by all subcomponents of this menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * component, unless those subcomponents specify a different font.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * Some platforms may not support setting of all font attributes
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   300
     * of a menu component; in such cases, calling {@code setFont}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * will have no effect on the unsupported font attributes of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * menu component.  Unless subcomponents of this menu component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * specify a different font, this font will be used by those
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * subcomponents if supported by the underlying platform.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * @param     f   the font to be set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @see       #getFont
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * @see       Font#getAttributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @see       java.awt.font.TextAttribute
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    public void setFont(Font f) {
30918
ee2374d4aae3 7155957: closed/java/awt/MenuBar/MenuBarStress1/MenuBarStress1.java hangs on win 64 bit with jdk8
ssadetsky
parents: 30471
diff changeset
   312
        synchronized (getTreeLock()) {
ee2374d4aae3 7155957: closed/java/awt/MenuBar/MenuBarStress1/MenuBarStress1.java hangs on win 64 bit with jdk8
ssadetsky
parents: 30471
diff changeset
   313
            font = f;
ee2374d4aae3 7155957: closed/java/awt/MenuBar/MenuBarStress1/MenuBarStress1.java hangs on win 64 bit with jdk8
ssadetsky
parents: 30471
diff changeset
   314
            //Fixed 6312943: NullPointerException in method MenuComponent.setFont(Font)
ee2374d4aae3 7155957: closed/java/awt/MenuBar/MenuBarStress1/MenuBarStress1.java hangs on win 64 bit with jdk8
ssadetsky
parents: 30471
diff changeset
   315
            MenuComponentPeer peer = this.peer;
ee2374d4aae3 7155957: closed/java/awt/MenuBar/MenuBarStress1/MenuBarStress1.java hangs on win 64 bit with jdk8
ssadetsky
parents: 30471
diff changeset
   316
            if (peer != null) {
ee2374d4aae3 7155957: closed/java/awt/MenuBar/MenuBarStress1/MenuBarStress1.java hangs on win 64 bit with jdk8
ssadetsky
parents: 30471
diff changeset
   317
                peer.setFont(f);
ee2374d4aae3 7155957: closed/java/awt/MenuBar/MenuBarStress1/MenuBarStress1.java hangs on win 64 bit with jdk8
ssadetsky
parents: 30471
diff changeset
   318
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * Removes the menu component's peer.  The peer allows us to modify the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * appearance of the menu component without changing the functionality of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * the menu component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    public void removeNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        synchronized (getTreeLock()) {
15994
5c8a3d840366 8007295: Reduce number of warnings in awt classes
mcherkas
parents: 13604
diff changeset
   329
            MenuComponentPeer p = this.peer;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            if (p != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                Toolkit.getEventQueue().removeSourceEvents(this, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                this.peer = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                p.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * Posts the specified event to the menu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * This method is part of the Java&nbsp;1.0 event system
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * and it is maintained only for backwards compatibility.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * Its use is discouraged, and it may not be supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * in the future.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * @param evt the event which is to take place
29886
545c0c3809b8 8075081: Fix missing doclint warnings in java.awt
darcy
parents: 25859
diff changeset
   345
     * @return unconditionally returns false
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * @deprecated As of JDK version 1.1, replaced by {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * #dispatchEvent(AWTEvent) dispatchEvent}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    public boolean postEvent(Event evt) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        MenuContainer parent = this.parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        if (parent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
            parent.postEvent(evt);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * Delivers an event to this component or one of its sub components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * @param e the event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    public final void dispatchEvent(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        dispatchEventImpl(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    void dispatchEventImpl(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        EventQueue.setCurrentEventAndMostRecentTime(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        Toolkit.getDefaultToolkit().notifyAWTEventListeners(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        if (newEventsOnly ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            (parent != null && parent instanceof MenuComponent &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
             ((MenuComponent)parent).newEventsOnly)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            if (eventEnabled(e)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                processEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            } else if (e instanceof ActionEvent && parent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                e.setSource(parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                ((MenuComponent)parent).dispatchEvent(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        } else { // backward compatibility
43722
25ba19c20260 8143077: Deprecate InputEvent._MASK in favor of InputEvent._DOWN_MASK
serb
parents: 42740
diff changeset
   382
            @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            Event olde = e.convertToOld();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            if (olde != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                postEvent(olde);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    // REMIND: remove when filtering is done at lower level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    boolean eventEnabled(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * Processes events occurring on this menu component.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   396
     * <p>Note that if the event parameter is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * the behavior is unspecified and may result in an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * @param e the event
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23010
diff changeset
   401
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    protected void processEvent(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * Returns a string representing the state of this
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   408
     * {@code MenuComponent}. This method is intended to be used
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * only for debugging purposes, and the content and format of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * returned string may vary between implementations. The returned
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   411
     * string may be empty but may not be {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @return     the parameter string of this menu component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        String thisName = getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        return (thisName != null? thisName : "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * Returns a representation of this menu component as a string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * @return  a string representation of this menu component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        return getClass().getName() + "[" + paramString() + "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * Gets this component's locking object (the object that owns the thread
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 15994
diff changeset
   430
     * synchronization monitor) for AWT component-tree and layout
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * @return this component's locking object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    protected final Object getTreeLock() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        return Component.LOCK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * Reads the menu component from an object input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   441
     * @param s the {@code ObjectInputStream} to read
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * @exception HeadlessException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   443
     *   {@code GraphicsEnvironment.isHeadless} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   444
     *   {@code true}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        throws ClassNotFoundException, IOException, HeadlessException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        GraphicsEnvironment.checkHeadless();
8816
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   452
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   453
        acc = AccessController.getContext();
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   454
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        appContext = AppContext.getAppContext();
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
     * Initialize JNI field and method IDs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * --- Accessibility Support ---
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     *  MenuComponent will contain all of the methods in interface Accessible,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     *  though it won't actually implement the interface - that will be up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     *  to the individual objects which extend MenuComponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     */
58309
c6f8b2c3dc66 8231334: Suppress warnings on non-serializable instance fields in client libs serializable classes
darcy
parents: 47216
diff changeset
   473
    @SuppressWarnings("serial") // Not statically typed as Serializable
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    AccessibleContext accessibleContext = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   477
     * Gets the {@code AccessibleContext} associated with
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   478
     * this {@code MenuComponent}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   480
     * The method implemented by this base class returns {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   481
     * Classes that extend {@code MenuComponent}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * should implement this method to return the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   483
     * {@code AccessibleContext} associated with the subclass.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   485
     * @return the {@code AccessibleContext} of this
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   486
     *     {@code MenuComponent}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   494
     * Inner class of {@code MenuComponent} used to provide
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * default support for accessibility.  This class is not meant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * to be used directly by application developers, but is instead
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * meant only to be subclassed by menu component developers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * The class used to obtain the accessible role for this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    protected abstract class AccessibleAWTMenuComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        extends AccessibleContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        implements java.io.Serializable, AccessibleComponent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                   AccessibleSelection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
         * JDK 1.3 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        private static final long serialVersionUID = -4269533416223798698L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
         * Although the class is abstract, this should be called by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
         * all sub-classes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        protected AccessibleAWTMenuComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        // AccessibleContext methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   523
         * Gets the {@code AccessibleSelection} associated with this
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   524
         * object which allows its {@code Accessible} children to be selected.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   526
         * @return {@code AccessibleSelection} if supported by object;
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   527
         *      else return {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
         * @see AccessibleSelection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        public AccessibleSelection getAccessibleSelection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
            return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
         * Gets the accessible name of this object.  This should almost never
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   536
         * return {@code java.awt.MenuComponent.getName}, as that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
         * generally isn't a localized name, and doesn't have meaning for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
         * user.  If the object is fundamentally a text object (e.g. a menu item), the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
         * accessible name should be the text of the object (e.g. "save").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
         * If the object has a tooltip, the tooltip text may also be an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
         * appropriate String to return.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   543
         * @return the localized name of the object -- can be {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
         *         if this object does not have a name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
         * @see AccessibleContext#setAccessibleName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        public String getAccessibleName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            return accessibleName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
         * Gets the accessible description of this object.  This should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
         * a concise, localized description of what this object is - what
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
         * is its meaning to the user.  If the object has a tooltip, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
         * tooltip text may be an appropriate string to return, assuming
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
         * it contains a concise description of the object (instead of just
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
         * the name of the object - e.g. a "Save" icon on a toolbar that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
         * had "save" as the tooltip text shouldn't return the tooltip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
         * text as the description, but something like "Saves the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
         * text document" instead).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
         * @return the localized description of the object -- can be
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   563
         *     {@code null} if this object does not have a description
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
         * @see AccessibleContext#setAccessibleDescription
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        public String getAccessibleDescription() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
            return accessibleDescription;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
         * Gets the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   573
         * @return an instance of {@code AccessibleRole}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
         *     describing the role of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
         * @see AccessibleRole
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
            return AccessibleRole.AWT_COMPONENT; // Non-specific -- overridden in subclasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
         * Gets the state of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   584
         * @return an instance of {@code AccessibleStateSet}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
         *     containing the current state set of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
         * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
        public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
            return MenuComponent.this.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   593
         * Gets the {@code Accessible} parent of this object.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   594
         * If the parent of this object implements {@code Accessible},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   595
         * this method should simply return {@code getParent}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   597
         * @return the {@code Accessible} parent of this object -- can
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   598
         *    be {@code null} if this object does not have an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   599
         *    {@code Accessible} parent
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
        public Accessible getAccessibleParent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
            if (accessibleParent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
                return accessibleParent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                MenuContainer parent = MenuComponent.this.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                if (parent instanceof Accessible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                    return (Accessible) parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
         * Gets the index of this object in its accessible parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
         * @return the index of this object in its parent; -1 if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
         *     object does not have an accessible parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
         * @see #getAccessibleParent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        public int getAccessibleIndexInParent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
            return MenuComponent.this.getAccessibleIndexInParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
         * Returns the number of accessible children in the object.  If all
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   626
         * of the children of this object implement {@code Accessible},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
         * then this method should return the number of children of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
         * @return the number of accessible children in the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        public int getAccessibleChildrenCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            return 0; // MenuComponents don't have children
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   636
         * Returns the nth {@code Accessible} child of the object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
         * @param i zero-based index of child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
         * @return the nth Accessible child of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        public Accessible getAccessibleChild(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
            return null; // MenuComponents don't have children
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
         * Returns the locale of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
         * @return the locale of this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
        public java.util.Locale getLocale() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
            MenuContainer parent = MenuComponent.this.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
            if (parent instanceof Component)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
                return ((Component)parent).getLocale();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
                return java.util.Locale.getDefault();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   659
         * Gets the {@code AccessibleComponent} associated with
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   660
         * this object if one exists.  Otherwise return {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
         * @return the component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        public AccessibleComponent getAccessibleComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
            return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        // AccessibleComponent methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
         * Gets the background color of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
         * @return the background color, if supported, of the object;
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   675
         *     otherwise, {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        public Color getBackground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
            return null; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
         * Sets the background color of this object.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   683
         * (For transparency, see {@code isOpaque}.)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   685
         * @param c the new {@code Color} for the background
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
         * @see Component#isOpaque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        public void setBackground(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
         * Gets the foreground color of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
         * @return the foreground color, if supported, of the object;
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   696
         *     otherwise, {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        public Color getForeground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
            return null; // Not supported for MenuComponents
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 foreground color of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   705
         * @param c the new {@code Color} for the foreground
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        public void setForeground(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   712
         * Gets the {@code Cursor} of this object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   714
         * @return the {@code Cursor}, if supported, of the object;
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   715
         *     otherwise, {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
        public Cursor getCursor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
            return null; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   722
         * Sets the {@code Cursor} of this object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
         * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
         * The method may have no visual effect if the Java platform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
         * implementation and/or the native system do not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
         * changing the mouse cursor shape.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   727
         * @param cursor the new {@code Cursor} for the object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
        public void setCursor(Cursor cursor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   734
         * Gets the {@code Font} of this object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   736
         * @return the {@code Font},if supported, for the object;
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   737
         *     otherwise, {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        public Font getFont() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
            return MenuComponent.this.getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   744
         * Sets the {@code Font} of this object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   746
         * @param f the new {@code Font} for the object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        public void setFont(Font f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
            MenuComponent.this.setFont(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   753
         * Gets the {@code FontMetrics} of this object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   755
         * @param f the {@code Font}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
         * @return the FontMetrics, if supported, the object;
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   757
         *              otherwise, {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
         * @see #getFont
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        public FontMetrics getFontMetrics(Font f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
            return null; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
         * Determines if the object is enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
         * @return true if object is enabled; otherwise, false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
            return true; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
         * Sets the enabled state of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
         * @param b if true, enables this object; otherwise, disables it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        public void setEnabled(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
         * Determines if the object is visible.  Note: this means that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
         * object intends to be visible; however, it may not in fact be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
         * showing on the screen because one of the objects that this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
         * is contained by is not visible.  To determine if an object is
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   787
         * showing on the screen, use {@code isShowing}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
         * @return true if object is visible; otherwise, false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
        public boolean isVisible() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
            return true; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
         * Sets the visible state of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
         * @param b if true, shows this object; otherwise, hides it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
        public void setVisible(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
         * Determines if the object is showing.  This is determined by checking
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
         * the visibility of the object and ancestors of the object.  Note:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
         * this will return true even if the object is obscured by another
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
         * (for example, it happens to be underneath a menu that was pulled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
         * down).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
         * @return true if object is showing; otherwise, false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        public boolean isShowing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
            return true; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
         * Checks whether the specified point is within this object's bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
         * where the point's x and y coordinates are defined to be relative to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
         * the coordinate system of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   822
         * @param p the {@code Point} relative to the coordinate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
         *     system of the object
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   824
         * @return true if object contains {@code Point}; otherwise false
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        public boolean contains(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
            return false; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
         * Returns the location of the object on the screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   833
         * @return location of object on screen -- can be {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
         *     if this object is not on the screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
        public Point getLocationOnScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
            return null; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
         * Gets the location of the object relative to the parent in the form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
         * of a point specifying the object's top-left corner in the screen's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
         * coordinate space.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   845
         * @return an instance of {@code Point} representing the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
         *    top-left corner of the object's bounds in the coordinate
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   847
         *    space of the screen; {@code null} if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
         *    this object or its parent are not on the screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        public Point getLocation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
            return null; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
         * Sets the location of the object relative to the parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        public void setLocation(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
         * Gets the bounds of this object in the form of a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   863
         * {@code Rectangle} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
         * The bounds specify this object's width, height, and location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
         * relative to its parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
         * @return a rectangle indicating this component's bounds;
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   868
         *     {@code null} if this object is not on the screen
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        public Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
            return null; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
         * Sets the bounds of this object in the form of a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   876
         * {@code Rectangle} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
         * The bounds specify this object's width, height, and location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
         * relative to its parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
         * @param r a rectangle indicating this component's bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        public void setBounds(Rectangle r) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
         * Returns the size of this object in the form of a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   888
         * {@code Dimension} object. The height field of
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   889
         * the {@code Dimension} object contains this object's
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   890
         * height, and the width field of the {@code Dimension}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
         * object contains this object's width.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   893
         * @return a {@code Dimension} object that indicates the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   894
         *         size of this component; {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
         *         if this object is not on the screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
        public Dimension getSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
            return null; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
         * Resizes this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   904
         * @param d the {@code Dimension} specifying the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
         *    new size of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
        public void setSize(Dimension d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   912
         * Returns the {@code Accessible} child, if one exists,
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   913
         * contained at the local coordinate {@code Point}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   914
         * If there is no {@code Accessible} child, {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
         * is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
         * @param p the point defining the top-left corner of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   918
         *    {@code Accessible}, given in the coordinate space
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
         *    of the object's parent
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   920
         * @return the {@code Accessible}, if it exists,
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   921
         *    at the specified location; else {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
        public Accessible getAccessibleAt(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
            return null; // MenuComponents don't have children
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
         * Returns whether this object can accept focus or not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
         * @return true if object can accept focus; otherwise false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
        public boolean isFocusTraversable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
            return true; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
         * Requests focus for this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
        public void requestFocus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
            // Not supported for MenuComponents
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
         * Adds the specified focus listener to receive focus events from this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
         * component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
         * @param l the focus listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
        public void addFocusListener(java.awt.event.FocusListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
         * Removes the specified focus listener so it no longer receives focus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
         * events from this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
         * @param l the focus listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
        public void removeFocusListener(java.awt.event.FocusListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
        // AccessibleSelection methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   967
         * Returns the number of {@code Accessible} children currently selected.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
         * If no children are selected, the return value will be 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
         * @return the number of items currently selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
         public int getAccessibleSelectionCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
             return 0;  //  To be fully implemented in a future release
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   977
         * Returns an {@code Accessible} representing the specified
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
         * selected child in the object.  If there isn't a selection, or there are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
         * fewer children selected than the integer passed in, the return
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   980
         * value will be {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
         * <p>Note that the index represents the i-th selected child, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
         * is different from the i-th child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
         * @param i the zero-based index of selected children
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
         * @return the i-th selected child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
         * @see #getAccessibleSelectionCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
         public Accessible getAccessibleSelection(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
             return null;  //  To be fully implemented in a future release
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
         * Determines if the current child of this object is selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
         * @return true if the current child of this object is selected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
         *    else false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
         * @param i the zero-based index of the child in this
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   998
         *      {@code Accessible} object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
         * @see AccessibleContext#getAccessibleChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
         public boolean isAccessibleChildSelected(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
             return false;  //  To be fully implemented in a future release
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1006
         * Adds the specified {@code Accessible} child of the object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
         * to the object's selection.  If the object supports multiple selections,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
         * the specified child is added to any existing selection, otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
         * it replaces any existing selection in the object.  If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
         * specified child is already selected, this method has no effect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
         * @param i the zero-based index of the child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
         * @see AccessibleContext#getAccessibleChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
         public void addAccessibleSelection(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
               //  To be fully implemented in a future release
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
         * Removes the specified child of the object from the object's
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
         * selection.  If the specified item isn't currently selected, this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
         * method has no effect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
         * @param i the zero-based index of the child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
         * @see AccessibleContext#getAccessibleChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
         public void removeAccessibleSelection(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
               //  To be fully implemented in a future release
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
         * Clears the selection in the object, so that no children in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
         * object are selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
         public void clearAccessibleSelection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
               //  To be fully implemented in a future release
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
         * Causes every child of the object to be selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
         * if the object supports multiple selections.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
         public void selectAllAccessibleSelection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
               //  To be fully implemented in a future release
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
    } // inner class AccessibleAWTComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
     * Gets the index of this object in its accessible parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
     * @return -1 if this object does not have an accessible parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
     *      otherwise, the index of the child in its accessible parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
    int getAccessibleIndexInParent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
        MenuContainer localParent = parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
        if (!(localParent instanceof MenuComponent)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
            // MenuComponents only have accessible index when inside MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
            return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
        MenuComponent localParentMenu = (MenuComponent)localParent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
        return localParentMenu.getAccessibleChildIndex(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
     * Gets the index of the child within this MenuComponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
     * @param child MenuComponent whose index we are interested in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
     * @return -1 if this object doesn't contain the child,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
     *      otherwise, index of the child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
    int getAccessibleChildIndex(MenuComponent child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
        return -1; // Overridden in subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
     * Gets the state of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1079
     * @return an instance of {@code AccessibleStateSet}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
     *     containing the current state set of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
     * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
    AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
        AccessibleStateSet states = new AccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
        return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1088
}