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