APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing

public Class JMenuBar

extends JComponent
implements Accessible, MenuElement
Class Inheritance
All Implemented Interfaces
javax.swing.MenuElement, javax.accessibility.Accessible
Known Direct Subclasses
javax.swing.plaf.basic.BasicInternalFrameTitlePane.SystemMenuBar, javax.swing.plaf.metal.MetalTitlePane.SystemMenuBar
Annotations
@JavaBean
defaultProperty:UI
description:A container for holding and displaying menus.
@SwingContainer
@SuppressWarnings:serial
Imports
java.awt.Component, .Graphics, .Insets, .Toolkit, java.awt.event.KeyEvent, .MouseEvent, java.beans.BeanProperty, .JavaBean, .Transient, java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .Serial, .Serializable, java.util.ArrayList, javax.accessibility.Accessible, .AccessibleContext, .AccessibleRole, .AccessibleSelection, .AccessibleStateSet, javax.swing.plaf.MenuBarUI, sun.awt.SunToolkit

An implementation of a menu bar. You add JMenu objects to the menu bar to construct a menu. When the user selects a JMenu object, its associated JPopupMenu is displayed, allowing the user to select one of the JMenuItems on it.

For information and examples of using menu bars see How to Use Menus, a section in The Java Tutorial.

Warning

Swing is not thread safe. For more information see Swing's Threading Policy.

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Warning

By default, pressing the Tab key does not transfer focus from a JMenuBar which is added to a container together with other Swing components, because the focusTraversalKeysEnabled property of JMenuBar is set to false. To resolve this, you should call the JMenuBar.setFocusTraversalKeysEnabled(true) method.

Authors
Georges Saab, David Karlton, Arnaud Weber
Since
1.2
See Also
JMenu, JPopupMenu, JMenuItem

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected class
JMenuBar.AccessibleJMenuBar

This class implements accessibility support for the JMenuBar class.

Field Summary

Modifier and TypeField and Description
private static final boolean
private Insets
private boolean
private transient SingleSelectionModel
private static final boolean
private static final String
private static final boolean
Inherited from javax.swing.JComponent:
DEBUG_GRAPHICS_LOADEDfocusControllerivSourceComponentlistenerListpaintingChildTOOL_TIP_TEXT_KEYuiUNDEFINED_CONDITIONWHEN_ANCESTOR_OF_FOCUSED_COMPONENTWHEN_FOCUSEDWHEN_IN_FOCUSED_WINDOW

Constructor Summary

AccessConstructor and Description
public
JMenuBar()

Creates a new menu bar.

Method Summary

Modifier and TypeMethod and Description
public JMenu

Returns:

the menu component
add
(JMenu
the JMenu component to add
c
)

Appends the specified menu to the end of the menu bar.

public void
addNotify()

Overrides javax.swing.JComponent.addNotify.

Overrides JComponent.addNotify to register this menu bar with the current keyboard manager.

public AccessibleContext

Returns:

an AccessibleJMenuBar that serves as the AccessibleContext of this JMenuBar
getAccessibleContext
()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JMenuBar.

public Component

Returns:

the current Component (this)
getComponent
()

Implements javax.swing.MenuElement.getComponent.

Implemented to be a MenuElement.

public Component

Returns:

the Component at the position, or null for an invalid index
getComponentAtIndex
(int
an integer specifying the position, where 0 is first
i
)
Deprecated replaced by getComponent(int i)

Returns the component at the specified index.

public int

Returns:

an integer giving the component's position, where 0 is first; or -1 if it can't be found
getComponentIndex
(Component
the Component to find
c
)

Returns the index of the specified component.

public JMenu

Returns:

the JMenu that delivers help to the user
getHelpMenu
()

Gets the help menu for the menu bar.

public Insets

Returns:

an Insets object containing the margin values
getMargin
()

Returns the margin between the menubar's border and its menus.

public JMenu

Returns:

the JMenu at that position, or null if if there is no JMenu at that position (ie. if it is a JMenuItem)
getMenu
(int
an integer giving the position in the menu bar, where 0 is the first position
index
)

Returns the menu at the specified position in the menu bar.

public int

Returns:

the number of items in the menu bar
getMenuCount
()

Returns the number of items in the menu bar.

public SingleSelectionModel

Returns:

the SingleSelectionModel property
getSelectionModel
()

Returns the model object that handles single selections.

public MenuElement[]

Returns:

an array of menu items in the menu bar.
getSubElements
()

Implements javax.swing.MenuElement.getSubElements.

Implemented to be a MenuElement -- returns the menus in this menu bar.

public MenuBarUI

Returns:

a MenuBarUI which is the menubar's current L&F object
getUI
()

Overrides javax.swing.JComponent.getUI.

Returns the menubar's current UI.

public String

Returns:

the string "MenuBarUI"
getUIClassID
()

Overrides javax.swing.JComponent.getUIClassID.

Returns the name of the L&F class that renders this component.

public boolean

Returns:

true if the border should be painted, else false
isBorderPainted
()

Returns true if the menu bars border should be painted.

public boolean

Returns:

true if a selection has been made, else false
isSelected
()

Returns true if the menu bar currently has a component selected.

protected void
paintBorder(Graphics
the Graphics context to use for painting
g
)

Overrides javax.swing.JComponent.paintBorder.

Paints the menubar's border if BorderPainted property is true.

protected String

Returns:

a string representation of this JMenuBar
paramString
()

Overrides javax.swing.JComponent.paramString.

Returns a string representation of this JMenuBar.

pack-priv static boolean
processBindingForKeyStrokeRecursive(MenuElement elem, KeyStroke ks, KeyEvent e, int condition, boolean pressed)

protected boolean
processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed)

Overrides javax.swing.JComponent.processKeyBinding.

Subclassed to check all the child menus.

public void
processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager)

Implements javax.swing.MenuElement.processKeyEvent.

Implemented to be a MenuElement -- does nothing.

public void
processMouseEvent(MouseEvent event, MenuElement[] path, MenuSelectionManager manager)

Implements javax.swing.MenuElement.processMouseEvent.

Implemented to be a MenuElement -- does nothing.

private void
readObject(ObjectInputStream s)

Hides javax.swing.JComponent.readObject.

See JComponent.readObject() for information about serialization in Swing.

public void
removeNotify()

Overrides javax.swing.JComponent.removeNotify.

Overrides JComponent.removeNotify to unregister this menu bar with the current keyboard manager.

public void
setBorderPainted(boolean
if true and border property is not null, the border is painted.
b
)

Sets whether the border should be painted.

public void
setHelpMenu(JMenu
the JMenu that delivers help to the user
menu
)

Sets the help menu that appears when the user selects the "help" option in the menu bar.

public void
setMargin(Insets
an Insets object containing the margin values
m
)

Sets the margin between the menubar's border and its menus.

public void
setSelected(Component
the Component to select
sel
)

Sets the currently selected component, producing a a change to the selection model.

public void
setSelectionModel(SingleSelectionModel
the SingleSelectionModel to use
model
)

Sets the model object to handle single selections.

public void
setUI(MenuBarUI
the new MenuBarUI L&F object
ui
)

Sets the L&F object that renders this component.

public void
updateUI()

Overrides javax.swing.JComponent.updateUI.

Resets the UI property with a value from the current look and feel.

private void
writeObject(ObjectOutputStream s)

Hides javax.swing.JComponent.writeObject.

Before writing a JComponent to an ObjectOutputStream we temporarily uninstall its UI.

Inherited from javax.swing.JComponent:
_paintImmediatelyaddAncestorListeneraddVetoableChangeListeneralwaysOnTopcheckIfChildObscuredBySiblingclientPropertyChangedcomponentInputMapChangedcomputeVisibleRectcomputeVisibleRectcompWriteObjectNotifycontainscreateToolTipdisabledndDonedropLocationForPointenablefirePropertyChangefirePropertyChangefirePropertyChangefireVetoableChangegetActionForKeyStrokegetActionMapgetActionMapgetAlignmentXgetAlignmentYgetAncestorListenersgetAutoscrollsgetBaselinegetBaselineResizeBehaviorgetBordergetBoundsgetClientPropertygetComponentGraphicsgetComponentPopupMenugetConditionForKeyStrokegetCreatedDoubleBuffergetDebugGraphicsOptionsgetDefaultLocalegetFontMetricsgetGraphicsgetGraphicsInvokedgetHeightgetInheritsPopupMenugetInputMapgetInputMapgetInputMapgetInputVerifiergetInsetsgetInsetsgetListenersgetLocationgetManagingFocusBackwardTraversalKeysgetManagingFocusForwardTraversalKeysgetMaximumSizegetMinimumSizegetNextFocusableComponentgetPopupLocationgetPreferredSizegetRegisteredKeyStrokesgetRootPanegetSizegetToolTipLocationgetToolTipTextgetToolTipTextgetTopLevelAncestorgetTransferHandlergetVerifyInputWhenFocusTargetgetVetoableChangeListenersgetVisibleRectgetWidthgetWriteObjCountergetXgetYgrabFocushideisDoubleBufferedisLightweightComponentisManagingFocusisOpaqueisOptimizedDrawingEnabledisPaintingisPaintingForPrintisPaintingOriginisPaintingTileisRequestFocusEnabledisValidateRootpaintpaintChildrenpaintComponentpaintForceDoubleBufferedpaintImmediatelypaintImmediatelypaintToOffscreenprintprintAllprintBorderprintChildrenprintComponentprocessComponentKeyEventprocessKeyBindingsprocessKeyBindingsForAllComponentsprocessKeyEventprocessMouseEventprocessMouseMotionEventputClientPropertyrectangleIsObscuredregisterKeyboardActionregisterKeyboardActionremoveAncestorListenerremoveVetoableChangeListenerrepaintrepaintrequestDefaultFocusrequestFocusrequestFocusrequestFocusInWindowrequestFocusInWindowresetKeyboardActionsreshaperevalidatesafelyGetGraphicssafelyGetGraphicsscrollRectToVisiblesetActionMapsetAlignmentXsetAlignmentYsetAutoscrollssetBackgroundsetBordersetComponentPopupMenusetCreatedDoubleBuffersetDebugGraphicsOptionssetDefaultLocalesetDoubleBufferedsetDropLocationsetEnabledsetFocusTraversalKeyssetFontsetForegroundsetInheritsPopupMenusetInputMapsetInputVerifiersetMaximumSizesetMinimumSizesetNextFocusableComponentsetOpaquesetPaintingChildsetPreferredSizesetRequestFocusEnabledsetToolTipTextsetTransferHandlersetUIsetUIPropertysetVerifyInputWhenFocusTargetsetVisiblesetWriteObjCountershouldDebugGraphicssuperProcessMouseMotionEventunregisterKeyboardActionupdate

Field Detail

DEBUGback to summary
private static final boolean DEBUG
marginback to summary
private Insets margin
paintBorderback to summary
private boolean paintBorder
selectionModelback to summary
private transient SingleSelectionModel selectionModel
TRACEback to summary
private static final boolean TRACE
uiClassIDback to summary
private static final String uiClassID

Hides javax.swing.JComponent.uiClassID.

See Also
getUIClassID, readObject
VERBOSEback to summary
private static final boolean VERBOSE

Constructor Detail

JMenuBarback to summary
public JMenuBar()

Creates a new menu bar.

Method Detail

addback to summary
public JMenu add(JMenu c)

Appends the specified menu to the end of the menu bar.

Parameters
c:JMenu

the JMenu component to add

Returns:JMenu

the menu component

addNotifyback to summary
public void addNotify()

Overrides javax.swing.JComponent.addNotify.

Overrides JComponent.addNotify to register this menu bar with the current keyboard manager.

getAccessibleContextback to summary
public AccessibleContext getAccessibleContext()

Overrides java.awt.Component.getAccessibleContext.

Implements javax.accessibility.Accessible.getAccessibleContext.

Gets the AccessibleContext associated with this JMenuBar. For JMenuBars, the AccessibleContext takes the form of an AccessibleJMenuBar. A new AccessibleJMenuBar instance is created if necessary.

Returns:AccessibleContext

an AccessibleJMenuBar that serves as the AccessibleContext of this JMenuBar

Annotations
@BeanProperty
bound:false
getComponentback to summary
public Component getComponent()

Implements javax.swing.MenuElement.getComponent.

Implemented to be a MenuElement. Returns this object.

Returns:Component

the current Component (this)

See Also
getSubElements
getComponentAtIndexback to summary
public Component getComponentAtIndex(int i)

Deprecated

replaced by getComponent(int i)

Returns the component at the specified index.

Parameters
i:int

an integer specifying the position, where 0 is first

Returns:Component

the Component at the position, or null for an invalid index

Annotations
@Deprecated
getComponentIndexback to summary
public int getComponentIndex(Component c)

Returns the index of the specified component.

Parameters
c:Component

the Component to find

Returns:int

an integer giving the component's position, where 0 is first; or -1 if it can't be found

getHelpMenuback to summary
public JMenu getHelpMenu()

Gets the help menu for the menu bar. This method is not yet implemented and will throw an exception.

Returns:JMenu

the JMenu that delivers help to the user

Annotations
@Transient
getMarginback to summary
public Insets getMargin()

Returns the margin between the menubar's border and its menus. If there is no previous margin, it will create a default margin with zero size.

Returns:Insets

an Insets object containing the margin values

See Also
Insets
getMenuback to summary
public JMenu getMenu(int index)

Returns the menu at the specified position in the menu bar.

Parameters
index:int

an integer giving the position in the menu bar, where 0 is the first position

Returns:JMenu

the JMenu at that position, or null if if there is no JMenu at that position (ie. if it is a JMenuItem)

getMenuCountback to summary
public int getMenuCount()

Returns the number of items in the menu bar.

Returns:int

the number of items in the menu bar

Annotations
@BeanProperty
bound:false
getSelectionModelback to summary
public SingleSelectionModel getSelectionModel()

Returns the model object that handles single selections.

Returns:SingleSelectionModel

the SingleSelectionModel property

See Also
SingleSelectionModel
getSubElementsback to summary
public MenuElement[] getSubElements()

Implements javax.swing.MenuElement.getSubElements.

Implemented to be a MenuElement -- returns the menus in this menu bar. This is the reason for implementing the MenuElement interface -- so that the menu bar can be treated the same as other menu elements.

Returns:MenuElement[]

an array of menu items in the menu bar.

Annotations
@BeanProperty
bound:false
getUIback to summary
public MenuBarUI getUI()

Overrides javax.swing.JComponent.getUI.

Returns the menubar's current UI.

Returns:MenuBarUI

a MenuBarUI which is the menubar's current L&F object

See Also
setUI
getUIClassIDback to summary
public String getUIClassID()

Overrides javax.swing.JComponent.getUIClassID.

Returns the name of the L&F class that renders this component.

Returns:String

the string "MenuBarUI"

Annotations
@BeanProperty
bound:false
See Also
JComponent#getUIClassID, UIDefaults#getUI
isBorderPaintedback to summary
public boolean isBorderPainted()

Returns true if the menu bars border should be painted.

Returns:boolean

true if the border should be painted, else false

isSelectedback to summary
public boolean isSelected()

Returns true if the menu bar currently has a component selected.

Returns:boolean

true if a selection has been made, else false

Annotations
@BeanProperty
bound:false
paintBorderback to summary
protected void paintBorder(Graphics g)

Overrides javax.swing.JComponent.paintBorder.

Paints the menubar's border if BorderPainted property is true.

Parameters
g:Graphics

the Graphics context to use for painting

See Also
JComponent#paint, JComponent#setBorder
paramStringback to summary
protected String paramString()

Overrides javax.swing.JComponent.paramString.

Returns a string representation of this JMenuBar. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.

Returns:String

a string representation of this JMenuBar

processBindingForKeyStrokeRecursiveback to summary
pack-priv static boolean processBindingForKeyStrokeRecursive(MenuElement elem, KeyStroke ks, KeyEvent e, int condition, boolean pressed)
processKeyBindingback to summary
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed)

Overrides javax.swing.JComponent.processKeyBinding.

Subclassed to check all the child menus.

Since
1.3
processKeyEventback to summary
public void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager)

Implements javax.swing.MenuElement.processKeyEvent.

Implemented to be a MenuElement -- does nothing.

See Also
getSubElements
processMouseEventback to summary
public void processMouseEvent(MouseEvent event, MenuElement[] path, MenuSelectionManager manager)

Implements javax.swing.MenuElement.processMouseEvent.

Implemented to be a MenuElement -- does nothing.

See Also
getSubElements
readObjectback to summary
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException

Hides javax.swing.JComponent.readObject.

See JComponent.readObject() for information about serialization in Swing.

Annotations
@Serial
Exceptions
IOException:

Doc from java.awt.Container.readObject.

if an I/O error occurs

ClassNotFoundException:

Doc from java.awt.Container.readObject.

if the class of a serialized object could not be found

removeNotifyback to summary
public void removeNotify()

Overrides javax.swing.JComponent.removeNotify.

Overrides JComponent.removeNotify to unregister this menu bar with the current keyboard manager.

setBorderPaintedback to summary
public void setBorderPainted(boolean b)

Sets whether the border should be painted.

Parameters
b:boolean

if true and border property is not null, the border is painted.

Annotations
@BeanProperty
visualUpdate:true
description:Whether the border should be painted.
See Also
isBorderPainted
setHelpMenuback to summary
public void setHelpMenu(JMenu menu)

Sets the help menu that appears when the user selects the "help" option in the menu bar. This method is not yet implemented and will throw an exception.

Parameters
menu:JMenu

the JMenu that delivers help to the user

setMarginback to summary
public void setMargin(Insets m)

Sets the margin between the menubar's border and its menus. Setting to null will cause the menubar to use the default margins.

Parameters
m:Insets

an Insets object containing the margin values

Annotations
@BeanProperty
visualUpdate:true
description:The space between the menubar\'s border and its contents
See Also
Insets
setSelectedback to summary
public void setSelected(Component sel)

Sets the currently selected component, producing a a change to the selection model.

Parameters
sel:Component

the Component to select

setSelectionModelback to summary
public void setSelectionModel(SingleSelectionModel model)

Sets the model object to handle single selections.

Parameters
model:SingleSelectionModel

the SingleSelectionModel to use

Annotations
@BeanProperty
description:The selection model, recording which child is selected.
See Also
SingleSelectionModel
setUIback to summary
public void setUI(MenuBarUI ui)

Sets the L&F object that renders this component.

Parameters
ui:MenuBarUI

the new MenuBarUI L&F object

Annotations
@BeanProperty
hidden:true
visualUpdate:true
description:The UI object that implements the Component\'s LookAndFeel.
See Also
UIDefaults#getUI
updateUIback to summary
public void updateUI()

Overrides javax.swing.JComponent.updateUI.

Resets the UI property with a value from the current look and feel.

See Also
JComponent#updateUI
writeObjectback to summary
private void writeObject(ObjectOutputStream s) throws IOException

Hides javax.swing.JComponent.writeObject.

Doc from javax.swing.JComponent.writeObject.

Before writing a JComponent to an ObjectOutputStream we temporarily uninstall its UI. This is tricky to do because we want to uninstall the UI before any of the JComponent's children (or its LayoutManager etc.) are written, and we don't want to restore the UI until the most derived JComponent subclass has been stored.

Annotations
@Serial
Exceptions
IOException:

Doc from java.awt.Container.writeObject.

if an I/O error occurs

javax.swing back to summary

protected Class JMenuBar.AccessibleJMenuBar

extends AccessibleJComponent
implements AccessibleSelection
Class Inheritance
All Implemented Interfaces
javax.accessibility.AccessibleSelection
Annotations
@SuppressWarnings:serial

This class implements accessibility support for the JMenuBar class. It provides an implementation of the Java Accessibility API appropriate to menu bar user-interface elements.

Warning

Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans package. Please see java.beans.XMLEncoder.

Field Summary

Inherited from javax.swing.JComponent.AccessibleJComponent:
accessibleFocusHandler

Constructor Summary

AccessConstructor and Description
protected
AccessibleJMenuBar()

Constructs an AccessibleJMenuBar.

Method Summary

Modifier and TypeMethod and Description
public void
addAccessibleSelection(int
the zero-based index of selectable items
i
)

Implements javax.accessibility.AccessibleSelection.addAccessibleSelection.

Selects the nth menu in the menu bar, forcing it to pop up.

public void
clearAccessibleSelection()

Implements javax.accessibility.AccessibleSelection.clearAccessibleSelection.

Clears the selection in the object, so that nothing in the object is selected.

public AccessibleRole

Returns:

an instance of AccessibleRole describing the role of the object
getAccessibleRole
()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleRole.

Get the role of this object.

public AccessibleSelection

Returns:

this object
getAccessibleSelection
()

Overrides javax.accessibility.AccessibleContext.getAccessibleSelection.

Get the AccessibleSelection associated with this object.

public Accessible
getAccessibleSelection(int i)

Implements javax.accessibility.AccessibleSelection.getAccessibleSelection.

Returns the currently selected menu if one is selected, otherwise null.

public int

Returns:

1 if a menu is currently selected, else 0
getAccessibleSelectionCount
()

Implements javax.accessibility.AccessibleSelection.getAccessibleSelectionCount.

Returns 1 if a menu is currently selected in this menu bar.

public AccessibleStateSet

Returns:

an instance of AccessibleState containing the current state of the object
getAccessibleStateSet
()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleStateSet.

Get the accessible state set of this object.

public boolean
isAccessibleChildSelected(int
the zero-based index of the child in this Accessible object.
i
)

Implements javax.accessibility.AccessibleSelection.isAccessibleChildSelected.

Returns true if the current child of this object is selected.

public void
removeAccessibleSelection(int
the zero-based index of selectable items
i
)

Implements javax.accessibility.AccessibleSelection.removeAccessibleSelection.

Removes the nth selected item in the object from the object's selection.

public void
selectAllAccessibleSelection()

Implements javax.accessibility.AccessibleSelection.selectAllAccessibleSelection.

Normally causes every selected item in the object to be selected if the object supports multiple selections.

Inherited from javax.swing.JComponent.AccessibleJComponent:
addPropertyChangeListenergetAccessibleChildgetAccessibleChildrenCountgetAccessibleDescriptiongetAccessibleExtendedComponentgetAccessibleKeyBindinggetAccessibleNamegetBorderTitlegetTitledBorderTextgetToolTipTextremovePropertyChangeListener

Constructor Detail

AccessibleJMenuBarback to summary
protected AccessibleJMenuBar()

Constructs an AccessibleJMenuBar.

Method Detail

addAccessibleSelectionback to summary
public void addAccessibleSelection(int i)

Implements javax.accessibility.AccessibleSelection.addAccessibleSelection.

Selects the nth menu in the menu bar, forcing it to pop up. If another menu is popped up, this will force it to close. If the nth menu is already selected, this method has no effect.

Parameters
i:int

the zero-based index of selectable items

See Also
getAccessibleStateSet
clearAccessibleSelectionback to summary
public void clearAccessibleSelection()

Implements javax.accessibility.AccessibleSelection.clearAccessibleSelection.

Clears the selection in the object, so that nothing in the object is selected. This will close any open menu.

getAccessibleRoleback to summary
public AccessibleRole getAccessibleRole()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleRole.

Get the role of this object.

Returns:AccessibleRole

an instance of AccessibleRole describing the role of the object

getAccessibleSelectionback to summary
public AccessibleSelection getAccessibleSelection()

Overrides javax.accessibility.AccessibleContext.getAccessibleSelection.

Get the AccessibleSelection associated with this object. In the implementation of the Java Accessibility API for this class, return this object, which is responsible for implementing the AccessibleSelection interface on behalf of itself.

Returns:AccessibleSelection

this object

getAccessibleSelectionback to summary
public Accessible getAccessibleSelection(int i)

Implements javax.accessibility.AccessibleSelection.getAccessibleSelection.

Returns the currently selected menu if one is selected, otherwise null.

getAccessibleSelectionCountback to summary
public int getAccessibleSelectionCount()

Implements javax.accessibility.AccessibleSelection.getAccessibleSelectionCount.

Returns 1 if a menu is currently selected in this menu bar.

Returns:int

1 if a menu is currently selected, else 0

getAccessibleStateSetback to summary
public AccessibleStateSet getAccessibleStateSet()

Overrides javax.swing.JComponent.AccessibleJComponent.getAccessibleStateSet.

Get the accessible state set of this object.

Returns:AccessibleStateSet

an instance of AccessibleState containing the current state of the object

isAccessibleChildSelectedback to summary
public boolean isAccessibleChildSelected(int i)

Implements javax.accessibility.AccessibleSelection.isAccessibleChildSelected.

Returns true if the current child of this object is selected.

Parameters
i:int

the zero-based index of the child in this Accessible object.

See Also
AccessibleContext#getAccessibleChild
removeAccessibleSelectionback to summary
public void removeAccessibleSelection(int i)

Implements javax.accessibility.AccessibleSelection.removeAccessibleSelection.

Removes the nth selected item in the object from the object's selection. If the nth item isn't currently selected, this method has no effect. Otherwise, it closes the popup menu.

Parameters
i:int

the zero-based index of selectable items

selectAllAccessibleSelectionback to summary
public void selectAllAccessibleSelection()

Implements javax.accessibility.AccessibleSelection.selectAllAccessibleSelection.

Normally causes every selected item in the object to be selected if the object supports multiple selections. This method makes no sense in a menu bar, and so does nothing.