javax.swing
public class JMenuBar extends JComponent implements Accessible, MenuElement
Nested Class Summary | |
---|---|
protected class | JMenuBar.AccessibleJMenuBar
Provides accessibility support for JMenuBar .
|
Constructor Summary | |
---|---|
JMenuBar()
Creates a new JMenuBar object. |
Method Summary | |
---|---|
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() |
Component | getComponent()
Returns reference to this menu bar
|
Component | getComponentAtIndex(int i)
Returns component at the specified index.
|
int | getComponentIndex(Component c)
Returns index of the specified component
|
JMenu | getHelpMenu()
This method is not implemented and will throw an {@link 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 {@link
UIManager}, from the current look and feel. |
Parameters: c menu to add
Returns: reference to the added menu
Returns: reference to this menu bar
Deprecated: Replaced by getComponent(int)
Returns component at the specified index.Parameters: i index of the component to get
Returns: component at the specified index. Null is returned if component at the specified index doesn't exist.
Parameters: c Component to search for
Returns: index of the specified component. -1 is returned if specified component doesnt' exist in the menu bar.
Returns: This method never returns anything, it throws an exception.
null
, this method returns
new Insets(0, 0, 0, 0)
.
Returns: The margin (never null
).
See Also: setMargin
Parameters: index index to look for the menu
Returns: menu at specified index, or null if menu doesn't exist at the specified index.
Returns: number of menu's in this menu bar
Returns: selection model for this menu bar.
Returns: MenuElement[] array containing menues in this menu bar
Returns: The current "UI" property
Returns: The Look and Feel classID. "MenuBarUI"
Returns: true if menu bar paints its border and false otherwise
Returns: true if some menu in menu bar is selected and false otherwise
Parameters: isIncluded true if menuBar is included in the selection and false otherwise
Parameters: g The graphics context with which to paint the border
Returns: A string describing this JMenuBar
Parameters: ks the KeyStroke for the event e the KeyEvent for the event condition the focus condition for the binding pressed true if the key is pressed
Parameters: e event forwarded from MenuSelectionManager path path to the menu element from which event was generated manager MenuSelectionManager for the current menu hierarchy
Parameters: event event forwarded from MenuSelectionManager path path to the menu element from which event was generated manager MenuSelectionManager for the current menu hierarchy
Parameters: b indicates if menu bar's border should be painted.
Parameters: menu help menu
UNKNOWN: The specification states that this method is not yet implemented and should throw an exception.
Parameters: m the margin (null
permitted).
See Also: getMargin
Parameters: sel menu to select
Parameters: model SingleSelectionModel that needs to be set for this menu bar
Parameters: ui The new "UI" property