jdk/src/java.desktop/share/classes/java/awt/MenuComponent.java
author serb
Thu, 08 Dec 2016 08:11:47 -0800
changeset 42740 ad57210989cd
parent 35667 ed476aba94de
child 43722 25ba19c20260
permissions -rw-r--r--
8165769: Hang in the help menu item Reviewed-by: alexsch, aivanov
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            Event olde = e.convertToOld();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            if (olde != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                postEvent(olde);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    // REMIND: remove when filtering is done at lower level
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    boolean eventEnabled(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * Processes events occurring on this menu component.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   395
     * <p>Note that if the event parameter is {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * the behavior is unspecified and may result in an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * exception.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * @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
   400
     * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    protected void processEvent(AWTEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * Returns a string representing the state of this
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   407
     * {@code MenuComponent}. This method is intended to be used
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * only for debugging purposes, and the content and format of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     * returned string may vary between implementations. The returned
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   410
     * string may be empty but may not be {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * @return     the parameter string of this menu component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    protected String paramString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        String thisName = getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        return (thisName != null? thisName : "");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     * Returns a representation of this menu component as a string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * @return  a string representation of this menu component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        return getClass().getName() + "[" + paramString() + "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * 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
   429
     * synchronization monitor) for AWT component-tree and layout
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * operations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * @return this component's locking object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    protected final Object getTreeLock() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        return Component.LOCK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * Reads the menu component from an object input stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   440
     * @param s the {@code ObjectInputStream} to read
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * @exception HeadlessException if
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   442
     *   {@code GraphicsEnvironment.isHeadless} returns
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   443
     *   {@code true}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        throws ClassNotFoundException, IOException, HeadlessException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
        GraphicsEnvironment.checkHeadless();
8816
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   451
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   452
        acc = AccessController.getContext();
29f983feda95 6907662: System clipboard should ensure access restrictions
denis
parents: 5506
diff changeset
   453
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        appContext = AppContext.getAppContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * Initialize JNI field and method IDs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * --- Accessibility Support ---
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     *  MenuComponent will contain all of the methods in interface Accessible,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     *  though it won't actually implement the interface - that will be up
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     *  to the individual objects which extend MenuComponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    AccessibleContext accessibleContext = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   476
     * Gets the {@code AccessibleContext} associated with
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   477
     * this {@code MenuComponent}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   479
     * The method implemented by this base class returns {@code null}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   480
     * Classes that extend {@code MenuComponent}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * should implement this method to return the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   482
     * {@code AccessibleContext} associated with the subclass.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   484
     * @return the {@code AccessibleContext} of this
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   485
     *     {@code MenuComponent}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   493
     * Inner class of {@code MenuComponent} used to provide
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * default support for accessibility.  This class is not meant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * to be used directly by application developers, but is instead
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     * meant only to be subclassed by menu component developers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * The class used to obtain the accessible role for this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    protected abstract class AccessibleAWTMenuComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
        extends AccessibleContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        implements java.io.Serializable, AccessibleComponent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                   AccessibleSelection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
         * JDK 1.3 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        private static final long serialVersionUID = -4269533416223798698L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
         * Although the class is abstract, this should be called by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
         * all sub-classes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        protected AccessibleAWTMenuComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        // AccessibleContext methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   522
         * Gets the {@code AccessibleSelection} associated with this
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   523
         * object which allows its {@code Accessible} children to be selected.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   525
         * @return {@code AccessibleSelection} if supported by object;
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   526
         *      else return {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
         * @see AccessibleSelection
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        public AccessibleSelection getAccessibleSelection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
            return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
         * Gets the accessible name of this object.  This should almost never
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   535
         * return {@code java.awt.MenuComponent.getName}, as that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
         * generally isn't a localized name, and doesn't have meaning for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
         * user.  If the object is fundamentally a text object (e.g. a menu item), the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
         * accessible name should be the text of the object (e.g. "save").
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
         * If the object has a tooltip, the tooltip text may also be an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
         * appropriate String to return.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   542
         * @return the localized name of the object -- can be {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
         *         if this object does not have a name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
         * @see AccessibleContext#setAccessibleName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
        public String getAccessibleName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
            return accessibleName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
         * Gets the accessible description of this object.  This should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
         * a concise, localized description of what this object is - what
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
         * is its meaning to the user.  If the object has a tooltip, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
         * tooltip text may be an appropriate string to return, assuming
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
         * it contains a concise description of the object (instead of just
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
         * the name of the object - e.g. a "Save" icon on a toolbar that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
         * had "save" as the tooltip text shouldn't return the tooltip
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
         * text as the description, but something like "Saves the current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
         * text document" instead).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
         * @return the localized description of the object -- can be
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   562
         *     {@code null} if this object does not have a description
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
         * @see AccessibleContext#setAccessibleDescription
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
        public String getAccessibleDescription() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
            return accessibleDescription;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
         * Gets the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   572
         * @return an instance of {@code AccessibleRole}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
         *     describing the role of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
         * @see AccessibleRole
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            return AccessibleRole.AWT_COMPONENT; // Non-specific -- overridden in subclasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
         * Gets the state of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   583
         * @return an instance of {@code AccessibleStateSet}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
         *     containing the current state set of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
         * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
        public AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
            return MenuComponent.this.getAccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   592
         * Gets the {@code Accessible} parent of this object.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   593
         * If the parent of this object implements {@code Accessible},
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   594
         * this method should simply return {@code getParent}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   596
         * @return the {@code Accessible} parent of this object -- can
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   597
         *    be {@code null} if this object does not have an
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   598
         *    {@code Accessible} parent
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
        public Accessible getAccessibleParent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
            if (accessibleParent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
                return accessibleParent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
                MenuContainer parent = MenuComponent.this.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
                if (parent instanceof Accessible) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                    return (Accessible) parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
         * Gets the index of this object in its accessible parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
         * @return the index of this object in its parent; -1 if this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
         *     object does not have an accessible parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
         * @see #getAccessibleParent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
        public int getAccessibleIndexInParent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
            return MenuComponent.this.getAccessibleIndexInParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
         * Returns the number of accessible children in the object.  If all
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   625
         * of the children of this object implement {@code Accessible},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
         * then this method should return the number of children of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
         * @return the number of accessible children in the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        public int getAccessibleChildrenCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
            return 0; // MenuComponents don't have children
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   635
         * Returns the nth {@code Accessible} child of the object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
         * @param i zero-based index of child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
         * @return the nth Accessible child of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        public Accessible getAccessibleChild(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
            return null; // MenuComponents don't have children
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
         * Returns the locale of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
         * @return the locale of this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
        public java.util.Locale getLocale() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
            MenuContainer parent = MenuComponent.this.getParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
            if (parent instanceof Component)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                return ((Component)parent).getLocale();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
            else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                return java.util.Locale.getDefault();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   658
         * Gets the {@code AccessibleComponent} associated with
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   659
         * this object if one exists.  Otherwise return {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
         * @return the component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        public AccessibleComponent getAccessibleComponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
            return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        // AccessibleComponent methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
         * Gets the background color of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
         * @return the background color, if supported, of the object;
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   674
         *     otherwise, {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
        public Color getBackground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
            return null; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
         * Sets the background color of this object.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   682
         * (For transparency, see {@code isOpaque}.)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   684
         * @param c the new {@code Color} for the background
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
         * @see Component#isOpaque
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        public void setBackground(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
         * Gets the foreground color of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
         * @return the foreground color, if supported, of the object;
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   695
         *     otherwise, {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
        public Color getForeground() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
            return null; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
         * Sets the foreground color of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   704
         * @param c the new {@code Color} for the foreground
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
        public void setForeground(Color c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   711
         * Gets the {@code Cursor} of this object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   713
         * @return the {@code Cursor}, if supported, of the object;
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   714
         *     otherwise, {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        public Cursor getCursor() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
            return null; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   721
         * Sets the {@code Cursor} of this object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
         * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
         * The method may have no visual effect if the Java platform
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
         * implementation and/or the native system do not support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
         * changing the mouse cursor shape.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   726
         * @param cursor the new {@code Cursor} for the object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        public void setCursor(Cursor cursor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   733
         * Gets the {@code Font} of this object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   735
         * @return the {@code Font},if supported, for the object;
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   736
         *     otherwise, {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
        public Font getFont() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
            return MenuComponent.this.getFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   743
         * Sets the {@code Font} of this object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   745
         * @param f the new {@code Font} for the object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
        public void setFont(Font f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
            MenuComponent.this.setFont(f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   752
         * Gets the {@code FontMetrics} of this object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   754
         * @param f the {@code Font}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
         * @return the FontMetrics, if supported, the object;
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   756
         *              otherwise, {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
         * @see #getFont
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
        public FontMetrics getFontMetrics(Font f) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
            return null; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
         * Determines if the object is enabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
         * @return true if object is enabled; otherwise, false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
        public boolean isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
            return true; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
         * Sets the enabled state of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
         * @param b if true, enables this object; otherwise, disables it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        public void setEnabled(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
         * Determines if the object is visible.  Note: this means that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
         * object intends to be visible; however, it may not in fact be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
         * showing on the screen because one of the objects that this object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
         * 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
   786
         * showing on the screen, use {@code isShowing}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
         * @return true if object is visible; otherwise, false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        public boolean isVisible() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
            return true; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
         * Sets the visible state of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
         * @param b if true, shows this object; otherwise, hides it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        public void setVisible(boolean b) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
         * Determines if the object is showing.  This is determined by checking
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
         * the visibility of the object and ancestors of the object.  Note:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
         * this will return true even if the object is obscured by another
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
         * (for example, it happens to be underneath a menu that was pulled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
         * down).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
         * @return true if object is showing; otherwise, false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        public boolean isShowing() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
            return true; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
         * Checks whether the specified point is within this object's bounds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
         * where the point's x and y coordinates are defined to be relative to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
         * the coordinate system of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   821
         * @param p the {@code Point} relative to the coordinate
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
         *     system of the object
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   823
         * @return true if object contains {@code Point}; otherwise false
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        public boolean contains(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
            return false; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
         * Returns the location of the object on the screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   832
         * @return location of object on screen -- can be {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
         *     if this object is not on the screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
        public Point getLocationOnScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
            return null; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
         * Gets the location of the object relative to the parent in the form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
         * of a point specifying the object's top-left corner in the screen's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
         * coordinate space.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   844
         * @return an instance of {@code Point} representing the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
         *    top-left corner of the object's bounds in the coordinate
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   846
         *    space of the screen; {@code null} if
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
         *    this object or its parent are not on the screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
        public Point getLocation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
            return null; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
         * Sets the location of the object relative to the parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        public void setLocation(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
         * Gets the bounds of this object in the form of a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   862
         * {@code Rectangle} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
         * The bounds specify this object's width, height, and location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
         * relative to its parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
         * @return a rectangle indicating this component's bounds;
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   867
         *     {@code null} if this object is not on the screen
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
        public Rectangle getBounds() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
            return null; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
         * Sets the bounds of this object in the form of a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   875
         * {@code Rectangle} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
         * The bounds specify this object's width, height, and location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
         * relative to its parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
         * @param r a rectangle indicating this component's bounds
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        public void setBounds(Rectangle r) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
         * Returns the size of this object in the form of a
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   887
         * {@code Dimension} object. The height field of
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   888
         * the {@code Dimension} object contains this object's
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   889
         * height, and the width field of the {@code Dimension}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
         * object contains this object's width.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   892
         * @return a {@code Dimension} object that indicates the
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   893
         *         size of this component; {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
         *         if this object is not on the screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
        public Dimension getSize() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
            return null; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
         * Resizes this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
         *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   903
         * @param d the {@code Dimension} specifying the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
         *    new size of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
        public void setSize(Dimension d) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   911
         * Returns the {@code Accessible} child, if one exists,
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   912
         * contained at the local coordinate {@code Point}.
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   913
         * If there is no {@code Accessible} child, {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
         * is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
         * @param p the point defining the top-left corner of the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   917
         *    {@code Accessible}, given in the coordinate space
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
         *    of the object's parent
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   919
         * @return the {@code Accessible}, if it exists,
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   920
         *    at the specified location; else {@code null}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
        public Accessible getAccessibleAt(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
            return null; // MenuComponents don't have children
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
         * Returns whether this object can accept focus or not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
         * @return true if object can accept focus; otherwise false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
        public boolean isFocusTraversable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
            return true; // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
         * Requests focus for this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
        public void requestFocus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
         * Adds the specified focus listener to receive focus events from this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
         * component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
         * @param l the focus listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
        public void addFocusListener(java.awt.event.FocusListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
         * Removes the specified focus listener so it no longer receives focus
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
         * events from this component.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
         * @param l the focus listener
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
        public void removeFocusListener(java.awt.event.FocusListener l) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
            // Not supported for MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
        // AccessibleSelection methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   966
         * Returns the number of {@code Accessible} children currently selected.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
         * If no children are selected, the return value will be 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
         * @return the number of items currently selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
         public int getAccessibleSelectionCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
             return 0;  //  To be fully implemented in a future release
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   976
         * Returns an {@code Accessible} representing the specified
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
         * selected child in the object.  If there isn't a selection, or there are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
         * fewer children selected than the integer passed in, the return
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   979
         * value will be {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
         * <p>Note that the index represents the i-th selected child, which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
         * is different from the i-th child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
         * @param i the zero-based index of selected children
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
         * @return the i-th selected child
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
         * @see #getAccessibleSelectionCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
         public Accessible getAccessibleSelection(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
             return null;  //  To be fully implemented in a future release
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
         * Determines if the current child of this object is selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
         * @return true if the current child of this object is selected;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
         *    else false
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
         * @param i the zero-based index of the child in this
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
   997
         *      {@code Accessible} object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
         * @see AccessibleContext#getAccessibleChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
         public boolean isAccessibleChildSelected(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
             return false;  //  To be fully implemented in a future release
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
        /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1005
         * Adds the specified {@code Accessible} child of the object
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
         * to the object's selection.  If the object supports multiple selections,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
         * the specified child is added to any existing selection, otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
         * it replaces any existing selection in the object.  If the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
         * specified child is already selected, this method has no effect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
         * @param i the zero-based index of the child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
         * @see AccessibleContext#getAccessibleChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
         public void addAccessibleSelection(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
               //  To be fully implemented in a future release
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
         * Removes the specified child of the object from the object's
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
         * selection.  If the specified item isn't currently selected, this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
         * method has no effect.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
         * @param i the zero-based index of the child
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
         * @see AccessibleContext#getAccessibleChild
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
         public void removeAccessibleSelection(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
               //  To be fully implemented in a future release
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
         * Clears the selection in the object, so that no children in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
         * object are selected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
         public void clearAccessibleSelection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
               //  To be fully implemented in a future release
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
         * Causes every child of the object to be selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
         * if the object supports multiple selections.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1042
         public void selectAllAccessibleSelection() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
               //  To be fully implemented in a future release
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
         }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
    } // inner class AccessibleAWTComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
     * Gets the index of this object in its accessible parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
     * @return -1 if this object does not have an accessible parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
     *      otherwise, the index of the child in its accessible parent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
    int getAccessibleIndexInParent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
        MenuContainer localParent = parent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
        if (!(localParent instanceof MenuComponent)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
            // MenuComponents only have accessible index when inside MenuComponents
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
            return -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
        MenuComponent localParentMenu = (MenuComponent)localParent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
        return localParentMenu.getAccessibleChildIndex(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
     * Gets the index of the child within this MenuComponent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
     * @param child MenuComponent whose index we are interested in.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1068
     * @return -1 if this object doesn't contain the child,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
     *      otherwise, index of the child.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
    int getAccessibleChildIndex(MenuComponent child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
        return -1; // Overridden in subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
     * Gets the state of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
     *
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 32865
diff changeset
  1078
     * @return an instance of {@code AccessibleStateSet}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
     *     containing the current state set of the object
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
     * @see AccessibleState
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
    AccessibleStateSet getAccessibleStateSet() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
        AccessibleStateSet states = new AccessibleStateSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
        return states;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
}