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