|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JMenuBar
An implementation of a MenuBar. 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 the keyboard keys used by this component in the standard Look and Feel (L&F) renditions, see the JMenuBar key assignments.
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. A future release of Swing will provide support for long term persistence.
JMenu
,
JPopupMenu
,
JMenuItem
, Serialized FormInner Class Summary | |
protected class |
JMenuBar.AccessibleJMenuBar
The class used to obtain the accessible role for this object. |
Inner classes inherited from class javax.swing.JComponent |
JComponent.AccessibleJComponent |
Fields inherited from class javax.swing.JComponent |
accessibleContext,
listenerList,
TOOL_TIP_TEXT_KEY,
ui,
UNDEFINED_CONDITION,
WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
WHEN_FOCUSED,
WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT,
CENTER_ALIGNMENT,
LEFT_ALIGNMENT,
RIGHT_ALIGNMENT,
TOP_ALIGNMENT |
Constructor Summary | |
JMenuBar()
Creates a new menu bar. |
Method Summary | |
JMenu |
add(JMenu c)
Appends the specified menu to the end of the menu bar. |
void |
addNotify()
Overrides JComponent.addNotify to register this
menu bar with the current KeyboardManager . |
AccessibleContext |
getAccessibleContext()
Get the AccessibleContext associated with this JComponent |
Component |
getComponent()
Implemented to be a MenuElement. |
Component |
getComponentAtIndex(int i)
Returns the component at the specified index. |
int |
getComponentIndex(Component c)
Returns the index of the specified component. |
JMenu |
getHelpMenu()
Gets the help menu for the menu bar. |
Insets |
getMargin()
Returns the margin between the menubar's border and its menus. |
JMenu |
getMenu(int index)
Gets the menu at the specified position in the menu bar. |
int |
getMenuCount()
Returns the number of items in the menu bar. |
SingleSelectionModel |
getSelectionModel()
Returns the model object that handles single selections. |
MenuElement[] |
getSubElements()
Implemented to be a MenuElement -- returns the menus in this menu bar. |
MenuBarUI |
getUI()
Returns the menubar's current UI. |
String |
getUIClassID()
Returns the name of the L&F class that renders this component. |
boolean |
isBorderPainted()
Returns true if the Menubar's border should be painted. |
boolean |
isManagingFocus()
Returns true to indicate that this component manages focus events internally. |
boolean |
isSelected()
Returns true if the MenuBar currently has a component selected |
void |
menuSelectionChanged(boolean isIncluded)
Implemented to be a MenuElement -- does nothing. |
protected void |
paintBorder(Graphics g)
Paint the menubar's border if BorderPainted property is true. |
protected String |
paramString()
Returns a string representation of this JMenuBar. |
void |
processKeyEvent(KeyEvent e,
MenuElement[] path,
MenuSelectionManager manager)
Implemented to be a MenuElement -- does nothing. |
void |
processMouseEvent(MouseEvent event,
MenuElement[] path,
MenuSelectionManager manager)
Implemented to be a MenuElement -- does nothing. |
void |
removeNotify()
Overrides JComponent.removeNotify to unregister this
menu bar with the current KeyboardManager . |
void |
setBorderPainted(boolean b)
Sets whether the border should be painted. |
void |
setHelpMenu(JMenu menu)
Sets the help menu that appears when the user selects the "help" option in the menu bar. |
void |
setMargin(Insets m)
Sets the margin between the menubar's border and its menus. |
void |
setSelected(Component sel)
Sets the currently selected component, producing a a change to the selection model. |
void |
setSelectionModel(SingleSelectionModel model)
Set the model object to handle single selections. |
void |
setUI(MenuBarUI ui)
Sets the L&F object that renders this component. |
void |
updateUI()
Notification from the UIFactory that the L&F has changed. |
Methods inherited from class java.awt.Container |
add,
add,
add,
add,
add,
addContainerListener,
addImpl,
countComponents,
deliverEvent,
doLayout,
findComponentAt,
findComponentAt,
getComponent,
getComponentAt,
getComponentAt,
getComponentCount,
getComponents,
getLayout,
insets,
invalidate,
isAncestorOf,
layout,
list,
list,
locate,
minimumSize,
paintComponents,
preferredSize,
print,
printComponents,
processContainerEvent,
processEvent,
remove,
remove,
removeAll,
removeContainerListener,
setCursor,
setLayout,
validate,
validateTree |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public JMenuBar()
Method Detail |
public MenuBarUI getUI()
setUI(javax.swing.plaf.MenuBarUI)
public void setUI(MenuBarUI ui)
ui
- the new MenuBarUI L&F objectUIDefaults.getUI(javax.swing.JComponent)
public void updateUI()
JComponent.updateUI()
public String getUIClassID()
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
public SingleSelectionModel getSelectionModel()
SingleSelectionModel
public void setSelectionModel(SingleSelectionModel model)
model
- the SingleSelectionModel to useSingleSelectionModel
public JMenu add(JMenu c)
c
- the JMenu component to addpublic JMenu getMenu(int index)
index
- an int giving the position in the menu bar, where
0 is the first positionpublic int getMenuCount()
public void setHelpMenu(JMenu menu)
menu
- the JMenu that delivers help to the userpublic JMenu getHelpMenu()
public Component getComponentAtIndex(int i)
getComponent(int i)
instead.i
- an int specifying the position, where 0 = firstpublic int getComponentIndex(Component c)
c
- the Component to findpublic void setSelected(Component sel)
sel
- the Component to selectpublic boolean isSelected()
public boolean isBorderPainted()
public void setBorderPainted(boolean b)
b
- if true and border property is not null, the border is painted.isBorderPainted()
protected void paintBorder(Graphics g)
g
- the Graphics context to use for paintingJComponent.paint(java.awt.Graphics)
,
JComponent.setBorder(javax.swing.border.Border)
public void setMargin(Insets m)
margin
- an Insets object containing the margin valuesInsets
public Insets getMargin()
Insets
public void processMouseEvent(MouseEvent event, MenuElement[] path, MenuSelectionManager manager)
getSubElements()
public void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager)
getSubElements()
public void menuSelectionChanged(boolean isIncluded)
getSubElements()
public MenuElement[] getSubElements()
public Component getComponent()
getSubElements()
protected String paramString()
null
.public AccessibleContext getAccessibleContext()
public boolean isManagingFocus()
public void addNotify()
JComponent.addNotify
to register this
menu bar with the current KeyboardManager
.JComponent.registerKeyboardAction(java.awt.event.ActionListener, java.lang.String, javax.swing.KeyStroke, int)
public void removeNotify()
JComponent.removeNotify
to unregister this
menu bar with the current KeyboardManager
.JComponent.registerKeyboardAction(java.awt.event.ActionListener, java.lang.String, javax.swing.KeyStroke, int)
|
JavaTM 2 Platform Standard Edition |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |