| 
 | JavaTM 2 Platform Std. Ed. v1.4.2 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JMenuBar
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.
 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.  As of 1.4, support for long term storage
 of all JavaBeansTM
 has been added to the java.beans package.
 Please see XMLEncoder.
JMenu, 
JPopupMenu, 
JMenuItem| Nested Class Summary | |
| protected  class | JMenuBar.AccessibleJMenuBarThis class implements accessibility support for the JMenuBarclass. | 
| Nested classes inherited from class javax.swing.JComponent | 
| JComponent.AccessibleJComponent | 
| Nested classes inherited from class java.awt.Container | 
| Container.AccessibleAWTContainer | 
| Nested classes inherited from class java.awt.Component | 
| Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy | 
| Field Summary | 
| 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 | 
| Fields inherited from interface java.awt.image.ImageObserver | 
| ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH | 
| 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.addNotifyto register this
 menu bar with the current keyboard manager. | 
|  AccessibleContext | getAccessibleContext()Gets the AccessibleContext associated with this JMenuBar. | 
|  Component | getComponent()Implemented to be a MenuElement. | 
|  Component | getComponentAtIndex(int i)Deprecated. replaced by getComponent(int i) | 
|  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)Returns 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 menu bars border should be painted. | 
|  boolean | isSelected()Returns true if the menu bar currently has a component selected. | 
|  void | menuSelectionChanged(boolean isIncluded)Implemented to be a MenuElemen | 
| protected  void | paintBorder(Graphics g)Paints the menubar's border if BorderPaintedproperty is true. | 
| protected  String | paramString()Returns a string representation of this JMenuBar. | 
| protected  boolean | processKeyBinding(KeyStroke ks,
                  KeyEvent e,
                  int condition,
                  boolean pressed)Subclassed to check all the child menus. | 
|  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.removeNotifyto unregister this
 menu bar with the current keyboard manager. | 
|  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)Sets the model object to handle single selections. | 
|  void | setUI(MenuBarUI ui)Sets the L&F object that renders this component. | 
|  void | updateUI()Resets the UI property with a value from the current look and feel. | 
| 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()
updateUI in class JComponentJComponent.updateUI()public String getUIClassID()
getUIClassID in class JComponentJComponent.getUIClassID(), 
UIDefaults.getUI(javax.swing.JComponent)public SingleSelectionModel getSelectionModel()
SingleSelectionModel propertySingleSelectionModelpublic void setSelectionModel(SingleSelectionModel model)
model - the SingleSelectionModel to useSingleSelectionModelpublic JMenu add(JMenu c)
c - the JMenu component to add
public JMenu getMenu(int index)
index - an integer giving the position in the menu bar, where
               0 is the first position
JMenu at that position, or null if
 		if there is no JMenu at that position (ie. if
		it is a JMenuItem)public int getMenuCount()
public void setHelpMenu(JMenu menu)
menu - the JMenu that delivers help to the userpublic JMenu getHelpMenu()
JMenu that delivers help to the userpublic Component getComponentAtIndex(int i)
getComponent(int i)
i - an integer specifying the position, where 0 is first
Component at the position,
		or null for an invalid indexpublic int getComponentIndex(Component c)
c - the Component to find
public 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)
BorderPainted
 property is true.
paintBorder in class JComponentg - the Graphics context to use for paintingJComponent.paint(java.awt.Graphics), 
JComponent.setBorder(javax.swing.border.Border)public void setMargin(Insets m)
null will cause the menubar to
 use the default margins.
m - an Insets object containing the margin valuesInsetspublic Insets getMargin()
Insets object containing the margin valuesInsets
public void processMouseEvent(MouseEvent event,
                              MenuElement[] path,
                              MenuSelectionManager manager)
MenuElement -- does nothing.
processMouseEvent in interface MenuElementgetSubElements()
public void processKeyEvent(KeyEvent e,
                            MenuElement[] path,
                            MenuSelectionManager manager)
MenuElement -- does nothing.
processKeyEvent in interface MenuElementgetSubElements()public void menuSelectionChanged(boolean isIncluded)
MenuElement -- does nothing.
- 
- Specified by:
- menuSelectionChangedin interface- MenuElement
 
- 
- See Also:
- getSubElements()
 
public MenuElement[] getSubElements()
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.
getSubElements in interface MenuElementpublic Component getComponent()
MenuElement. Returns this object.
getComponent in interface MenuElementComponent (this)getSubElements()protected String paramString()
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.
paramString in class JComponentJMenuBarpublic AccessibleContext getAccessibleContext()
getAccessibleContext in interface AccessiblegetAccessibleContext in class JComponent
protected boolean processKeyBinding(KeyStroke ks,
                                    KeyEvent e,
                                    int condition,
                                    boolean pressed)
processKeyBinding in class JComponentks - the KeyStroke queriede - the KeyEventcondition - one of the following values:
 pressed - true if the key is pressed
public void addNotify()
JComponent.addNotify to register this
 menu bar with the current keyboard manager.
addNotify in class JComponentJComponent.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 keyboard manager.
removeNotify in class JComponentJComponent.registerKeyboardAction(java.awt.event.ActionListener, java.lang.String, javax.swing.KeyStroke, int)| 
 | JavaTM 2 Platform Std. Ed. v1.4.2 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Copyright 2003 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.