0N/A/*
2362N/A * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.swing;
0N/A
0N/Aimport java.awt.Component;
0N/Aimport java.awt.Dimension;
0N/Aimport java.awt.Graphics;
0N/Aimport java.awt.Insets;
0N/Aimport java.awt.Point;
0N/Aimport java.awt.Rectangle;
0N/Aimport java.awt.event.*;
243N/Aimport java.beans.Transient;
0N/Aimport java.util.Vector;
0N/Aimport java.util.Enumeration;
0N/A
0N/Aimport java.io.Serializable;
0N/Aimport java.io.ObjectOutputStream;
0N/Aimport java.io.ObjectInputStream;
0N/Aimport java.io.IOException;
0N/A
0N/Aimport javax.swing.event.*;
0N/Aimport javax.swing.border.Border;
0N/Aimport javax.swing.plaf.*;
0N/Aimport javax.accessibility.*;
0N/A
0N/A/**
0N/A * An implementation of a menu bar. You add <code>JMenu</code> objects to the
0N/A * menu bar to construct a menu. When the user selects a <code>JMenu</code>
0N/A * object, its associated <code>JPopupMenu</code> is displayed, allowing the
0N/A * user to select one of the <code>JMenuItems</code> on it.
0N/A * <p>
0N/A * For information and examples of using menu bars see
0N/A * <a
0N/A href="http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html">How to Use Menus</a>,
0N/A * a section in <em>The Java Tutorial.</em>
0N/A * <p>
0N/A * <strong>Warning:</strong> Swing is not thread safe. For more
0N/A * information see <a
0N/A * href="package-summary.html#threading">Swing's Threading
0N/A * Policy</a>.
0N/A * <p>
0N/A * <strong>Warning:</strong>
0N/A * Serialized objects of this class will not be compatible with
0N/A * future Swing releases. The current serialization support is
0N/A * appropriate for short term storage or RMI between applications running
0N/A * the same version of Swing. As of 1.4, support for long term storage
0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup>
0N/A * has been added to the <code>java.beans</code> package.
0N/A * Please see {@link java.beans.XMLEncoder}.
0N/A *
0N/A * @beaninfo
0N/A * attribute: isContainer true
0N/A * description: A container for holding and displaying menus.
0N/A *
0N/A * @author Georges Saab
0N/A * @author David Karlton
0N/A * @author Arnaud Weber
0N/A * @see JMenu
0N/A * @see JPopupMenu
0N/A * @see JMenuItem
0N/A */
0N/Apublic class JMenuBar extends JComponent implements Accessible,MenuElement
0N/A{
0N/A /**
0N/A * @see #getUIClassID
0N/A * @see #readObject
0N/A */
0N/A private static final String uiClassID = "MenuBarUI";
0N/A
0N/A /*
0N/A * Model for the selected subcontrol.
0N/A */
0N/A private transient SingleSelectionModel selectionModel;
0N/A
0N/A private boolean paintBorder = true;
0N/A private Insets margin = null;
0N/A
0N/A /* diagnostic aids -- should be false for production builds. */
0N/A private static final boolean TRACE = false; // trace creates and disposes
0N/A private static final boolean VERBOSE = false; // show reuse hits/misses
0N/A private static final boolean DEBUG = false; // show bad params, misc.
0N/A
0N/A /**
0N/A * Creates a new menu bar.
0N/A */
0N/A public JMenuBar() {
0N/A super();
0N/A setFocusTraversalKeysEnabled(false);
0N/A setSelectionModel(new DefaultSingleSelectionModel());
0N/A updateUI();
0N/A }
0N/A
0N/A /**
0N/A * Returns the menubar's current UI.
0N/A * @see #setUI
0N/A */
0N/A public MenuBarUI getUI() {
0N/A return (MenuBarUI)ui;
0N/A }
0N/A
0N/A /**
0N/A * Sets the L&F object that renders this component.
0N/A *
0N/A * @param ui the new MenuBarUI L&F object
0N/A * @see UIDefaults#getUI
0N/A * @beaninfo
0N/A * bound: true
0N/A * hidden: true
0N/A * attribute: visualUpdate true
0N/A * description: The UI object that implements the Component's LookAndFeel.
0N/A */
0N/A public void setUI(MenuBarUI ui) {
0N/A super.setUI(ui);
0N/A }
0N/A
0N/A /**
0N/A * Resets the UI property with a value from the current look and feel.
0N/A *
0N/A * @see JComponent#updateUI
0N/A */
0N/A public void updateUI() {
0N/A setUI((MenuBarUI)UIManager.getUI(this));
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Returns the name of the L&F class that renders this component.
0N/A *
0N/A * @return the string "MenuBarUI"
0N/A * @see JComponent#getUIClassID
0N/A * @see UIDefaults#getUI
0N/A */
0N/A public String getUIClassID() {
0N/A return uiClassID;
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Returns the model object that handles single selections.
0N/A *
0N/A * @return the <code>SingleSelectionModel</code> property
0N/A * @see SingleSelectionModel
0N/A */
0N/A public SingleSelectionModel getSelectionModel() {
0N/A return selectionModel;
0N/A }
0N/A
0N/A /**
0N/A * Sets the model object to handle single selections.
0N/A *
0N/A * @param model the <code>SingleSelectionModel</code> to use
0N/A * @see SingleSelectionModel
0N/A * @beaninfo
0N/A * bound: true
0N/A * description: The selection model, recording which child is selected.
0N/A */
0N/A public void setSelectionModel(SingleSelectionModel model) {
0N/A SingleSelectionModel oldValue = selectionModel;
0N/A this.selectionModel = model;
0N/A firePropertyChange("selectionModel", oldValue, selectionModel);
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Appends the specified menu to the end of the menu bar.
0N/A *
0N/A * @param c the <code>JMenu</code> component to add
0N/A * @return the menu component
0N/A */
0N/A public JMenu add(JMenu c) {
0N/A super.add(c);
0N/A return c;
0N/A }
0N/A
0N/A /**
0N/A * Returns the menu at the specified position in the menu bar.
0N/A *
0N/A * @param index an integer giving the position in the menu bar, where
0N/A * 0 is the first position
0N/A * @return the <code>JMenu</code> at that position, or <code>null</code> if
0N/A * if there is no <code>JMenu</code> at that position (ie. if
0N/A * it is a <code>JMenuItem</code>)
0N/A */
0N/A public JMenu getMenu(int index) {
0N/A Component c = getComponentAtIndex(index);
0N/A if (c instanceof JMenu)
0N/A return (JMenu) c;
0N/A return null;
0N/A }
0N/A
0N/A /**
0N/A * Returns the number of items in the menu bar.
0N/A *
0N/A * @return the number of items in the menu bar
0N/A */
0N/A public int getMenuCount() {
0N/A return getComponentCount();
0N/A }
0N/A
0N/A /**
0N/A * Sets the help menu that appears when the user selects the
0N/A * "help" option in the menu bar. This method is not yet implemented
0N/A * and will throw an exception.
0N/A *
0N/A * @param menu the JMenu that delivers help to the user
0N/A */
0N/A public void setHelpMenu(JMenu menu) {
0N/A throw new Error("setHelpMenu() not yet implemented.");
0N/A }
0N/A
0N/A /**
0N/A * Gets the help menu for the menu bar. This method is not yet
0N/A * implemented and will throw an exception.
0N/A *
0N/A * @return the <code>JMenu</code> that delivers help to the user
0N/A */
243N/A @Transient
0N/A public JMenu getHelpMenu() {
0N/A throw new Error("getHelpMenu() not yet implemented.");
0N/A }
0N/A
0N/A /**
0N/A * Returns the component at the specified index.
0N/A *
0N/A * @param i an integer specifying the position, where 0 is first
0N/A * @return the <code>Component</code> at the position,
0N/A * or <code>null</code> for an invalid index
0N/A * @deprecated replaced by <code>getComponent(int i)</code>
0N/A */
0N/A @Deprecated
0N/A public Component getComponentAtIndex(int i) {
0N/A if(i < 0 || i >= getComponentCount()) {
0N/A return null;
0N/A }
0N/A return getComponent(i);
0N/A }
0N/A
0N/A /**
0N/A * Returns the index of the specified component.
0N/A *
0N/A * @param c the <code>Component</code> to find
0N/A * @return an integer giving the component's position, where 0 is first;
0N/A * or -1 if it can't be found
0N/A */
0N/A public int getComponentIndex(Component c) {
0N/A int ncomponents = this.getComponentCount();
0N/A Component[] component = this.getComponents();
0N/A for (int i = 0 ; i < ncomponents ; i++) {
0N/A Component comp = component[i];
0N/A if (comp == c)
0N/A return i;
0N/A }
0N/A return -1;
0N/A }
0N/A
0N/A /**
0N/A * Sets the currently selected component, producing a
0N/A * a change to the selection model.
0N/A *
0N/A * @param sel the <code>Component</code> to select
0N/A */
0N/A public void setSelected(Component sel) {
0N/A SingleSelectionModel model = getSelectionModel();
0N/A int index = getComponentIndex(sel);
0N/A model.setSelectedIndex(index);
0N/A }
0N/A
0N/A /**
0N/A * Returns true if the menu bar currently has a component selected.
0N/A *
0N/A * @return true if a selection has been made, else false
0N/A */
0N/A public boolean isSelected() {
0N/A return selectionModel.isSelected();
0N/A }
0N/A
0N/A /**
0N/A * Returns true if the menu bars border should be painted.
0N/A *
0N/A * @return true if the border should be painted, else false
0N/A */
0N/A public boolean isBorderPainted() {
0N/A return paintBorder;
0N/A }
0N/A
0N/A /**
0N/A * Sets whether the border should be painted.
0N/A *
0N/A * @param b if true and border property is not <code>null</code>,
0N/A * the border is painted.
0N/A * @see #isBorderPainted
0N/A * @beaninfo
0N/A * bound: true
0N/A * attribute: visualUpdate true
0N/A * description: Whether the border should be painted.
0N/A */
0N/A public void setBorderPainted(boolean b) {
0N/A boolean oldValue = paintBorder;
0N/A paintBorder = b;
0N/A firePropertyChange("borderPainted", oldValue, paintBorder);
0N/A if (b != oldValue) {
0N/A revalidate();
0N/A repaint();
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Paints the menubar's border if <code>BorderPainted</code>
0N/A * property is true.
0N/A *
0N/A * @param g the <code>Graphics</code> context to use for painting
0N/A * @see JComponent#paint
0N/A * @see JComponent#setBorder
0N/A */
0N/A protected void paintBorder(Graphics g) {
0N/A if (isBorderPainted()) {
0N/A super.paintBorder(g);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Sets the margin between the menubar's border and
0N/A * its menus. Setting to <code>null</code> will cause the menubar to
0N/A * use the default margins.
0N/A *
0N/A * @param m an Insets object containing the margin values
0N/A * @see Insets
0N/A * @beaninfo
0N/A * bound: true
0N/A * attribute: visualUpdate true
0N/A * description: The space between the menubar's border and its contents
0N/A */
0N/A public void setMargin(Insets m) {
0N/A Insets old = margin;
0N/A this.margin = m;
0N/A firePropertyChange("margin", old, m);
0N/A if (old == null || !old.equals(m)) {
0N/A revalidate();
0N/A repaint();
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Returns the margin between the menubar's border and
0N/A * its menus. If there is no previous margin, it will create
0N/A * a default margin with zero size.
0N/A *
0N/A * @return an <code>Insets</code> object containing the margin values
0N/A * @see Insets
0N/A */
0N/A public Insets getMargin() {
0N/A if(margin == null) {
0N/A return new Insets(0,0,0,0);
0N/A } else {
0N/A return margin;
0N/A }
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Implemented to be a <code>MenuElement</code> -- does nothing.
0N/A *
0N/A * @see #getSubElements
0N/A */
0N/A public void processMouseEvent(MouseEvent event,MenuElement path[],MenuSelectionManager manager) {
0N/A }
0N/A
0N/A /**
0N/A * Implemented to be a <code>MenuElement</code> -- does nothing.
0N/A *
0N/A * @see #getSubElements
0N/A */
0N/A public void processKeyEvent(KeyEvent e,MenuElement path[],MenuSelectionManager manager) {
0N/A }
0N/A
0N/A /**
0N/A * Implemented to be a <code>MenuElement</code> -- does nothing.
0N/A *
0N/A * @see #getSubElements
0N/A */
0N/A public void menuSelectionChanged(boolean isIncluded) {
0N/A }
0N/A
0N/A /**
0N/A * Implemented to be a <code>MenuElement</code> -- returns the
0N/A * menus in this menu bar.
0N/A * This is the reason for implementing the <code>MenuElement</code>
0N/A * interface -- so that the menu bar can be treated the same as
0N/A * other menu elements.
0N/A * @return an array of menu items in the menu bar.
0N/A */
0N/A public MenuElement[] getSubElements() {
0N/A MenuElement result[];
625N/A Vector<MenuElement> tmp = new Vector<MenuElement>();
0N/A int c = getComponentCount();
0N/A int i;
0N/A Component m;
0N/A
0N/A for(i=0 ; i < c ; i++) {
0N/A m = getComponent(i);
0N/A if(m instanceof MenuElement)
625N/A tmp.addElement((MenuElement) m);
0N/A }
0N/A
0N/A result = new MenuElement[tmp.size()];
0N/A for(i=0,c=tmp.size() ; i < c ; i++)
625N/A result[i] = tmp.elementAt(i);
0N/A return result;
0N/A }
0N/A
0N/A /**
0N/A * Implemented to be a <code>MenuElement</code>. Returns this object.
0N/A *
0N/A * @return the current <code>Component</code> (this)
0N/A * @see #getSubElements
0N/A */
0N/A public Component getComponent() {
0N/A return this;
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Returns a string representation of this <code>JMenuBar</code>.
0N/A * This method
0N/A * is intended to be used only for debugging purposes, and the
0N/A * content and format of the returned string may vary between
0N/A * implementations. The returned string may be empty but may not
0N/A * be <code>null</code>.
0N/A *
0N/A * @return a string representation of this <code>JMenuBar</code>
0N/A */
0N/A protected String paramString() {
0N/A String paintBorderString = (paintBorder ?
0N/A "true" : "false");
0N/A String marginString = (margin != null ?
0N/A margin.toString() : "");
0N/A
0N/A return super.paramString() +
0N/A ",margin=" + marginString +
0N/A ",paintBorder=" + paintBorderString;
0N/A }
0N/A
0N/A/////////////////
0N/A// Accessibility support
0N/A////////////////
0N/A
0N/A /**
0N/A * Gets the AccessibleContext associated with this JMenuBar.
0N/A * For JMenuBars, the AccessibleContext takes the form of an
0N/A * AccessibleJMenuBar.
0N/A * A new AccessibleJMenuBar instance is created if necessary.
0N/A *
0N/A * @return an AccessibleJMenuBar that serves as the
0N/A * AccessibleContext of this JMenuBar
0N/A */
0N/A public AccessibleContext getAccessibleContext() {
0N/A if (accessibleContext == null) {
0N/A accessibleContext = new AccessibleJMenuBar();
0N/A }
0N/A return accessibleContext;
0N/A }
0N/A
0N/A /**
0N/A * This class implements accessibility support for the
0N/A * <code>JMenuBar</code> class. It provides an implementation of the
0N/A * Java Accessibility API appropriate to menu bar user-interface
0N/A * elements.
0N/A * <p>
0N/A * <strong>Warning:</strong>
0N/A * Serialized objects of this class will not be compatible with
0N/A * future Swing releases. The current serialization support is
0N/A * appropriate for short term storage or RMI between applications running
0N/A * the same version of Swing. As of 1.4, support for long term storage
0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup>
0N/A * has been added to the <code>java.beans</code> package.
0N/A * Please see {@link java.beans.XMLEncoder}.
0N/A */
0N/A protected class AccessibleJMenuBar extends AccessibleJComponent
0N/A implements AccessibleSelection {
0N/A
0N/A /**
0N/A * Get the accessible state set of this object.
0N/A *
0N/A * @return an instance of AccessibleState containing the current state
0N/A * of the object
0N/A */
0N/A public AccessibleStateSet getAccessibleStateSet() {
0N/A AccessibleStateSet states = super.getAccessibleStateSet();
0N/A return states;
0N/A }
0N/A
0N/A /**
0N/A * Get the role of this object.
0N/A *
0N/A * @return an instance of AccessibleRole describing the role of the
0N/A * object
0N/A */
0N/A public AccessibleRole getAccessibleRole() {
0N/A return AccessibleRole.MENU_BAR;
0N/A }
0N/A
0N/A /**
0N/A * Get the AccessibleSelection associated with this object. In the
0N/A * implementation of the Java Accessibility API for this class,
0N/A * return this object, which is responsible for implementing the
0N/A * AccessibleSelection interface on behalf of itself.
0N/A *
0N/A * @return this object
0N/A */
0N/A public AccessibleSelection getAccessibleSelection() {
0N/A return this;
0N/A }
0N/A
0N/A /**
0N/A * Returns 1 if a menu is currently selected in this menu bar.
0N/A *
0N/A * @return 1 if a menu is currently selected, else 0
0N/A */
0N/A public int getAccessibleSelectionCount() {
0N/A if (isSelected()) {
0N/A return 1;
0N/A } else {
0N/A return 0;
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Returns the currently selected menu if one is selected,
0N/A * otherwise null.
0N/A */
0N/A public Accessible getAccessibleSelection(int i) {
0N/A if (isSelected()) {
0N/A if (i != 0) { // single selection model for JMenuBar
0N/A return null;
0N/A }
0N/A int j = getSelectionModel().getSelectedIndex();
0N/A if (getComponentAtIndex(j) instanceof Accessible) {
0N/A return (Accessible) getComponentAtIndex(j);
0N/A }
0N/A }
0N/A return null;
0N/A }
0N/A
0N/A /**
0N/A * Returns true if the current child of this object is selected.
0N/A *
0N/A * @param i the zero-based index of the child in this Accessible
0N/A * object.
0N/A * @see AccessibleContext#getAccessibleChild
0N/A */
0N/A public boolean isAccessibleChildSelected(int i) {
0N/A return (i == getSelectionModel().getSelectedIndex());
0N/A }
0N/A
0N/A /**
0N/A * Selects the nth menu in the menu bar, forcing it to
0N/A * pop up. If another menu is popped up, this will force
0N/A * it to close. If the nth menu is already selected, this
0N/A * method has no effect.
0N/A *
0N/A * @param i the zero-based index of selectable items
0N/A * @see #getAccessibleStateSet
0N/A */
0N/A public void addAccessibleSelection(int i) {
0N/A // first close up any open menu
0N/A int j = getSelectionModel().getSelectedIndex();
0N/A if (i == j) {
0N/A return;
0N/A }
0N/A if (j >= 0 && j < getMenuCount()) {
0N/A JMenu menu = getMenu(j);
0N/A if (menu != null) {
0N/A MenuSelectionManager.defaultManager().setSelectedPath(null);
0N/A// menu.setPopupMenuVisible(false);
0N/A }
0N/A }
0N/A // now popup the new menu
0N/A getSelectionModel().setSelectedIndex(i);
0N/A JMenu menu = getMenu(i);
0N/A if (menu != null) {
0N/A MenuElement me[] = new MenuElement[3];
0N/A me[0] = JMenuBar.this;
0N/A me[1] = menu;
0N/A me[2] = menu.getPopupMenu();
0N/A MenuSelectionManager.defaultManager().setSelectedPath(me);
0N/A// menu.setPopupMenuVisible(true);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Removes the nth selected item in the object from the object's
0N/A * selection. If the nth item isn't currently selected, this
0N/A * method has no effect. Otherwise, it closes the popup menu.
0N/A *
0N/A * @param i the zero-based index of selectable items
0N/A */
0N/A public void removeAccessibleSelection(int i) {
0N/A if (i >= 0 && i < getMenuCount()) {
0N/A JMenu menu = getMenu(i);
0N/A if (menu != null) {
0N/A MenuSelectionManager.defaultManager().setSelectedPath(null);
0N/A// menu.setPopupMenuVisible(false);
0N/A }
0N/A getSelectionModel().setSelectedIndex(-1);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Clears the selection in the object, so that nothing in the
0N/A * object is selected. This will close any open menu.
0N/A */
0N/A public void clearAccessibleSelection() {
0N/A int i = getSelectionModel().getSelectedIndex();
0N/A if (i >= 0 && i < getMenuCount()) {
0N/A JMenu menu = getMenu(i);
0N/A if (menu != null) {
0N/A MenuSelectionManager.defaultManager().setSelectedPath(null);
0N/A// menu.setPopupMenuVisible(false);
0N/A }
0N/A }
0N/A getSelectionModel().setSelectedIndex(-1);
0N/A }
0N/A
0N/A /**
0N/A * Normally causes every selected item in the object to be selected
0N/A * if the object supports multiple selections. This method
0N/A * makes no sense in a menu bar, and so does nothing.
0N/A */
0N/A public void selectAllAccessibleSelection() {
0N/A }
0N/A } // internal class AccessibleJMenuBar
0N/A
0N/A
0N/A /**
0N/A * Subclassed to check all the child menus.
0N/A * @since 1.3
0N/A */
0N/A protected boolean processKeyBinding(KeyStroke ks, KeyEvent e,
0N/A int condition, boolean pressed) {
0N/A // See if we have a local binding.
0N/A boolean retValue = super.processKeyBinding(ks, e, condition, pressed);
0N/A if (!retValue) {
0N/A MenuElement[] subElements = getSubElements();
625N/A for (MenuElement subElement : subElements) {
0N/A if (processBindingForKeyStrokeRecursive(
625N/A subElement, ks, e, condition, pressed)) {
0N/A return true;
0N/A }
0N/A }
0N/A }
0N/A return retValue;
0N/A }
0N/A
0N/A static boolean processBindingForKeyStrokeRecursive(MenuElement elem,
0N/A KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
0N/A if (elem == null) {
0N/A return false;
0N/A }
0N/A
0N/A Component c = elem.getComponent();
0N/A
0N/A if ( !(c.isVisible() || (c instanceof JPopupMenu)) || !c.isEnabled() ) {
0N/A return false;
0N/A }
0N/A
0N/A if (c != null && c instanceof JComponent &&
0N/A ((JComponent)c).processKeyBinding(ks, e, condition, pressed)) {
0N/A
0N/A return true;
0N/A }
0N/A
0N/A MenuElement[] subElements = elem.getSubElements();
625N/A for (MenuElement subElement : subElements) {
625N/A if (processBindingForKeyStrokeRecursive(subElement, ks, e, condition, pressed)) {
0N/A return true;
0N/A // We don't, pass along to children JMenu's
0N/A }
0N/A }
0N/A return false;
0N/A }
0N/A
0N/A /**
0N/A * Overrides <code>JComponent.addNotify</code> to register this
0N/A * menu bar with the current keyboard manager.
0N/A */
0N/A public void addNotify() {
0N/A super.addNotify();
0N/A KeyboardManager.getCurrentManager().registerMenuBar(this);
0N/A }
0N/A
0N/A /**
0N/A * Overrides <code>JComponent.removeNotify</code> to unregister this
0N/A * menu bar with the current keyboard manager.
0N/A */
0N/A public void removeNotify() {
0N/A super.removeNotify();
0N/A KeyboardManager.getCurrentManager().unregisterMenuBar(this);
0N/A }
0N/A
0N/A
0N/A private void writeObject(ObjectOutputStream s) throws IOException {
0N/A s.defaultWriteObject();
0N/A if (getUIClassID().equals(uiClassID)) {
0N/A byte count = JComponent.getWriteObjCounter(this);
0N/A JComponent.setWriteObjCounter(this, --count);
0N/A if (count == 0 && ui != null) {
0N/A ui.installUI(this);
0N/A }
0N/A }
0N/A
0N/A Object[] kvData = new Object[4];
0N/A int n = 0;
0N/A
0N/A if (selectionModel instanceof Serializable) {
0N/A kvData[n++] = "selectionModel";
0N/A kvData[n++] = selectionModel;
0N/A }
0N/A
0N/A s.writeObject(kvData);
0N/A }
0N/A
0N/A
0N/A /**
0N/A * See JComponent.readObject() for information about serialization
0N/A * in Swing.
0N/A */
0N/A private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException
0N/A {
0N/A s.defaultReadObject();
0N/A Object[] kvData = (Object[])(s.readObject());
0N/A
0N/A for(int i = 0; i < kvData.length; i += 2) {
0N/A if (kvData[i] == null) {
0N/A break;
0N/A }
0N/A else if (kvData[i].equals("selectionModel")) {
0N/A selectionModel = (SingleSelectionModel)kvData[i + 1];
0N/A }
0N/A }
0N/A
0N/A }
0N/A}