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