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