jdk/src/share/classes/java/awt/MenuBar.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
child 13604 31089af1a447
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1995, 2006, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.ObjectInputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.peer.MenuBarPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.event.KeyEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import javax.accessibility.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * The <code>MenuBar</code> class encapsulates the platform's
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * concept of a menu bar bound to a frame. In order to associate
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * the menu bar with a <code>Frame</code> object, call the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * frame's <code>setMenuBar</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * <A NAME="mbexample"></A><!-- target for cross references -->
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * This is what a menu bar might look like:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <img src="doc-files/MenuBar-1.gif"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * <alt="Diagram of MenuBar containing 2 menus: Examples and Options.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * Examples menu is expanded showing items: Basic, Simple, Check, and More Examples."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * ALIGN=center HSPACE=10 VSPACE=7>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * A menu bar handles keyboard shortcuts for menu items, passing them
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * along to its child menus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * (Keyboard shortcuts, which are optional, provide the user with
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * an alternative to the mouse for invoking a menu item and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * action that is associated with it.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * Each menu item can maintain an instance of <code>MenuShortcut</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * The <code>MenuBar</code> class defines several methods,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * {@link MenuBar#shortcuts} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * {@link MenuBar#getShortcutMenuItem}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * that retrieve information about the shortcuts a given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * menu bar is managing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * @author Sami Shaio
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * @see        java.awt.Frame
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * @see        java.awt.Frame#setMenuBar(java.awt.MenuBar)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * @see        java.awt.Menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * @see        java.awt.MenuItem
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * @see        java.awt.MenuShortcut
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * @since      JDK1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
public class MenuBar extends MenuComponent implements MenuContainer, Accessible {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        /* ensure that the necessary native libraries are loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        Toolkit.loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        if (!GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * This field represents a vector of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * actual menus that will be part of the MenuBar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     * @see #countMenus()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    Vector menus = new Vector();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * This menu is a special menu dedicated to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * help.  The one thing to note about this menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * is that on some platforms it appears at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * right edge of the menubar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * @see #getHelpMenu()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * @see #setHelpMenu(Menu)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    Menu helpMenu;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    private static final String base = "menubar";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    private static int nameCounter = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     private static final long serialVersionUID = -4930327919388951260L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * Creates a new menu bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @exception HeadlessException if GraphicsEnvironment.isHeadless()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * returns true.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public MenuBar() throws HeadlessException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * Construct a name for this MenuComponent.  Called by getName() when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * the name is null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    String constructComponentName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        synchronized (MenuBar.class) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            return base + nameCounter++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * Creates the menu bar's peer.  The peer allows us to change the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * appearance of the menu bar without changing any of the menu bar's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * functionality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    public void addNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
            if (peer == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                peer = Toolkit.getDefaultToolkit().createMenuBar(this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
            int nmenus = getMenuCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            for (int i = 0 ; i < nmenus ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                getMenu(i).addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * Removes the menu bar's peer.  The peer allows us to change the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * appearance of the menu bar without changing any of the menu bar's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * functionality.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    public void removeNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            int nmenus = getMenuCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            for (int i = 0 ; i < nmenus ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                getMenu(i).removeNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            super.removeNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * Gets the help menu on the menu bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * @return    the help menu on this menu bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public Menu getHelpMenu() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        return helpMenu;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * Sets the specified menu to be this menu bar's help menu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * If this menu bar has an existing help menu, the old help menu is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * removed from the menu bar, and replaced with the specified menu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @param m    the menu to be set as the help menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    public void setHelpMenu(Menu m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            if (helpMenu == m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            if (helpMenu != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                remove(helpMenu);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            if (m.parent != this) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                add(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            helpMenu = m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            if (m != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                m.isHelpMenu = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                m.parent = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                MenuBarPeer peer = (MenuBarPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                    if (m.peer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                        m.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                    peer.addHelpMenu(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            }
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
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * Adds the specified menu to the menu bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * If the menu has been part of another menu bar,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * removes it from that menu bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @param        m   the menu to be added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @return       the menu added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @see          java.awt.MenuBar#remove(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @see          java.awt.MenuBar#remove(java.awt.MenuComponent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public Menu add(Menu m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            if (m.parent != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                m.parent.remove(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            menus.addElement(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            m.parent = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            MenuBarPeer peer = (MenuBarPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                if (m.peer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                    m.addNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                peer.addMenu(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            return m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * Removes the menu located at the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * index from this menu bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * @param        index   the position of the menu to be removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * @see          java.awt.MenuBar#add(java.awt.Menu)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    public void remove(int index) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            Menu m = getMenu(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            menus.removeElementAt(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            MenuBarPeer peer = (MenuBarPeer)this.peer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                m.removeNotify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                m.parent = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                peer.delMenu(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * Removes the specified menu component from this menu bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * @param        m the menu component to be removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * @see          java.awt.MenuBar#add(java.awt.Menu)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    public void remove(MenuComponent m) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        synchronized (getTreeLock()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            int index = menus.indexOf(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
            if (index >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                remove(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * Gets the number of menus on the menu bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * @return     the number of menus on the menu bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * @since      JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    public int getMenuCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        return countMenus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * @deprecated As of JDK version 1.1,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * replaced by <code>getMenuCount()</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    public int countMenus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        return getMenuCountImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * This is called by the native code, so client code can't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * be called on the toolkit thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    final int getMenuCountImpl() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        return menus.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * Gets the specified menu.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * @param      i the index position of the menu to be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * @return     the menu at the specified index of this menu bar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    public Menu getMenu(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        return getMenuImpl(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * This is called by the native code, so client code can't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * be called on the toolkit thread.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    final Menu getMenuImpl(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        return (Menu)menus.elementAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * Gets an enumeration of all menu shortcuts this menu bar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * is managing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @return      an enumeration of menu shortcuts that this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     *                      menu bar is managing.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * @see         java.awt.MenuShortcut
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * @since       JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    public synchronized Enumeration<MenuShortcut> shortcuts() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        Vector shortcuts = new Vector();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        int nmenus = getMenuCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        for (int i = 0 ; i < nmenus ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            Enumeration e = getMenu(i).shortcuts();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            while (e.hasMoreElements()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                shortcuts.addElement(e.nextElement());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        return shortcuts.elements();
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
     * Gets the instance of <code>MenuItem</code> associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * with the specified <code>MenuShortcut</code> object,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * or <code>null</code> if none of the menu items being managed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * by this menu bar is associated with the specified menu
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * shortcut.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * @param        s the specified menu shortcut.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * @see          java.awt.MenuItem
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * @see          java.awt.MenuShortcut
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * @since        JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     public MenuItem getShortcutMenuItem(MenuShortcut s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        int nmenus = getMenuCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        for (int i = 0 ; i < nmenus ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
            MenuItem mi = getMenu(i).getShortcutMenuItem(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            if (mi != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                return mi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        return null;  // MenuShortcut wasn't found
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * Post an ACTION_EVENT to the target of the MenuPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * associated with the specified keyboard event (on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * keydown).  Returns true if there is an associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * keyboard event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    boolean handleShortcut(KeyEvent e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        // Is it a key event?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        int id = e.getID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        if (id != KeyEvent.KEY_PRESSED && id != KeyEvent.KEY_RELEASED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        // Is the accelerator modifier key pressed?
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        int accelKey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        if ((e.getModifiers() & accelKey) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        // Pass MenuShortcut on to child menus.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        int nmenus = getMenuCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        for (int i = 0 ; i < nmenus ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
            Menu m = getMenu(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            if (m.handleShortcut(e)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * Deletes the specified menu shortcut.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * @param     s the menu shortcut to delete.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * @since     JDK1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    public void deleteShortcut(MenuShortcut s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        int nmenus = getMenuCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        for (int i = 0 ; i < nmenus ; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            getMenu(i).deleteShortcut(s);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    /* Serialization support.  Restore the (transient) parent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * fields of Menubar menus here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * The MenuBar's serialized data version.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    private int menuBarSerializedDataVersion = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * Writes default serializable fields to stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * @param s the <code>ObjectOutputStream</code> to write
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * @see AWTEventMulticaster#save(ObjectOutputStream, String, EventListener)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * @see #readObject(java.io.ObjectInputStream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    private void writeObject(java.io.ObjectOutputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
      throws java.lang.ClassNotFoundException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
             java.io.IOException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
      s.defaultWriteObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * Reads the <code>ObjectInputStream</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * Unrecognized keys or values will be ignored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * @param s the <code>ObjectInputStream</code> to read
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * @exception HeadlessException if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     *   <code>GraphicsEnvironment.isHeadless</code> returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     *   <code>true</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * @see java.awt.GraphicsEnvironment#isHeadless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     * @see #writeObject(java.io.ObjectOutputStream)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    private void readObject(ObjectInputStream s)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
      throws ClassNotFoundException, IOException, HeadlessException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
      // HeadlessException will be thrown from MenuComponent's readObject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
      s.defaultReadObject();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
      for (int i = 0; i < menus.size(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
        Menu m = (Menu)menus.elementAt(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        m.parent = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * Initialize JNI field and method IDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
/////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
// Accessibility support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
////////////////
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * Gets the AccessibleContext associated with this MenuBar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * For menu bars, the AccessibleContext takes the form of an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * AccessibleAWTMenuBar.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * A new AccessibleAWTMenuBar instance is created if necessary.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * @return an AccessibleAWTMenuBar that serves as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     *         AccessibleContext of this MenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    public AccessibleContext getAccessibleContext() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        if (accessibleContext == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
            accessibleContext = new AccessibleAWTMenuBar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        return accessibleContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * Defined in MenuComponent. Overridden here.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    int getAccessibleChildIndex(MenuComponent child) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        return menus.indexOf(child);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * Inner class of MenuBar used to provide default support for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     * accessibility.  This class is not meant to be used directly by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * application developers, but is instead meant only to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * subclassed by menu component developers.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     * This class implements accessibility support for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     * <code>MenuBar</code> class.  It provides an implementation of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     * Java Accessibility API appropriate to menu bar user-interface elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    protected class AccessibleAWTMenuBar extends AccessibleAWTMenuComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
         * JDK 1.3 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        private static final long serialVersionUID = -8577604491830083815L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
         * Get the role of this object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
         * @return an instance of AccessibleRole describing the role of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
         * object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
         * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        public AccessibleRole getAccessibleRole() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            return AccessibleRole.MENU_BAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    } // class AccessibleAWTMenuBar
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
}