public class JMenuBar extends JComponent implements Accessible, MenuElement
| Modifier and Type | Class and Description |
|---|---|
protected class |
JMenuBar.AccessibleJMenuBar
Provides accessibility support for
JMenuBar. |
JComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategyaccessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
JMenuBar()
Creates a new JMenuBar object.
|
| Modifier and Type | Method and Description |
|---|---|
JMenu |
add(JMenu c)
Adds menu to the menu bar
|
void |
addNotify()
This method overrides addNotify() in the Container to register
this menu bar with the current keyboard manager.
|
AccessibleContext |
getAccessibleContext()
Get the value of the accessibleContext property for this component.
|
Component |
getComponent()
Returns reference to this menu bar
|
Component |
getComponentAtIndex(int i)
Deprecated.
Replaced by getComponent(int)
|
int |
getComponentIndex(Component c)
Returns index of the specified component
|
JMenu |
getHelpMenu()
This method is not implemented and will throw an
Error if called. |
Insets |
getMargin()
Returns the margin between the menu bar's border and its menus.
|
JMenu |
getMenu(int index)
Return menu at the specified index.
|
int |
getMenuCount()
Returns number of menu's in this menu bar
|
SingleSelectionModel |
getSelectionModel()
Returns selection model for this menu bar.
|
MenuElement[] |
getSubElements()
Method of MenuElement interface.
|
MenuBarUI |
getUI()
Set the "UI" property of the menu bar, which is a look and feel class
responsible for handling the menuBar's input events and painting it.
|
String |
getUIClassID()
This method returns a name to identify which look and feel class will be
the UI delegate for the menu bar.
|
boolean |
isBorderPainted()
Returns true if menu bar paints its border and false otherwise
|
boolean |
isSelected()
Returns true if some menu in menu bar is selected.
|
void |
menuSelectionChanged(boolean isIncluded)
This method does nothing by default.
|
protected void |
paintBorder(Graphics g)
Paints border of the menu bar, if its borderPainted property is set to
true.
|
protected String |
paramString()
A string that describes this JMenuBar.
|
protected boolean |
processKeyBinding(KeyStroke ks,
KeyEvent e,
int condition,
boolean pressed)
This method overrides JComponent.processKeyBinding to allow the
JMenuBar to check all the child components (recursiveley) to see
if they'll consume the event.
|
void |
processKeyEvent(KeyEvent e,
MenuElement[] path,
MenuSelectionManager manager)
Process key events forwarded from MenuSelectionManager.
|
void |
processMouseEvent(MouseEvent event,
MenuElement[] path,
MenuSelectionManager manager)
Process mouse events forwarded from MenuSelectionManager.
|
void |
removeNotify()
This method overrides removeNotify() in the Container to
unregister this menu bar from the current keyboard manager.
|
void |
setBorderPainted(boolean b)
Sets painting status of the border.
|
void |
setHelpMenu(JMenu menu)
Sets help menu for this menu bar
|
void |
setMargin(Insets m)
Sets the margin between the menu bar's border and its menus (this is a
bound property with the name 'margin').
|
void |
setSelected(Component sel)
Changes menu bar's selection to the specified menu.
|
void |
setSelectionModel(SingleSelectionModel model)
Sets menuBar's selection model to the one specified
|
void |
setUI(MenuBarUI ui)
Set the "UI" property of the menu bar, which is a look and feel class
responsible for handling menuBar's input events and painting it.
|
void |
updateUI()
Set the "UI" property to a class constructed, via the
UIManager, from the current look and feel. |
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic JMenuBar()
public JMenu add(JMenu c)
c - menu to addpublic void addNotify()
addNotify in class JComponentComponent.isDisplayable(),
Component.removeNotify()public AccessibleContext getAccessibleContext()
JComponentgetAccessibleContext in interface AccessiblegetAccessibleContext in class JComponentpublic Component getComponent()
getComponent in interface MenuElementpublic Component getComponentAtIndex(int i)
i - index of the component to getpublic int getComponentIndex(Component c)
c - Component to search forpublic JMenu getHelpMenu()
Error if called.public Insets getMargin()
null, this method returns
new Insets(0, 0, 0, 0).null).setMargin(Insets)public JMenu getMenu(int index)
index - index to look for the menupublic int getMenuCount()
public SingleSelectionModel getSelectionModel()
public MenuElement[] getSubElements()
getSubElements in interface MenuElementpublic MenuBarUI getUI()
public String getUIClassID()
getUIClassID in class JComponentJComponent.setUI(javax.swing.plaf.ComponentUI),
JComponent.updateUI()public boolean isBorderPainted()
public boolean isSelected()
public void menuSelectionChanged(boolean isIncluded)
menuSelectionChanged in interface MenuElementisIncluded - true if menuBar is included in the selection
and false otherwiseprotected void paintBorder(Graphics g)
paintBorder in class JComponentg - The graphics context with which to paint the borderJComponent.paint(java.awt.Graphics),
JComponent.paintChildren(java.awt.Graphics),
JComponent.paintComponent(java.awt.Graphics)protected String paramString()
paramString in class JComponentpublic void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager)
processKeyEvent in interface MenuElemente - event forwarded from MenuSelectionManagerpath - path to the menu element from which event was generatedmanager - MenuSelectionManager for the current menu hierarchyprotected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed)
processKeyBinding in class JComponentks - the KeyStroke for the evente - the KeyEvent for the eventcondition - the focus condition for the bindingpressed - true if the key is pressedpublic void processMouseEvent(MouseEvent event, MenuElement[] path, MenuSelectionManager manager)
processMouseEvent in interface MenuElementevent - event forwarded from MenuSelectionManagerpath - path to the menu element from which event was generatedmanager - MenuSelectionManager for the current menu hierarchypublic void removeNotify()
removeNotify in class JComponentComponent.isDisplayable(),
Component.addNotify()public void setBorderPainted(boolean b)
b - indicates if menu bar's border should be painted.public void setHelpMenu(JMenu menu)
menu - help menupublic void setMargin(Insets m)
m - the margin (null permitted).getMargin()public void setSelected(Component sel)
sel - menu to selectpublic void setSelectionModel(SingleSelectionModel model)
model - SingleSelectionModel that needs to be set for this menu barpublic void setUI(MenuBarUI ui)
ui - The new "UI" propertypublic void updateUI()
UIManager, from the current look and feel.updateUI in class JComponent