|
|||||||||
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
public class JMenuBar
JMenuBar is a container for menu's. For a menu bar to be seen on the screen, at least one menu should be added to it. Just like adding components to container, one can use add() to add menu's to the menu bar. Menu's will be displayed in the menu bar in the order they were added. The JMenuBar uses selectionModel to keep track of selected menu index. JMenuBar's selectionModel will fire ChangeEvents to its registered listeners when the selected index changes.
Nested Class Summary | |
---|---|
protected class |
JMenuBar.AccessibleJMenuBar
Provides accessibility support for JMenuBar . |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces 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 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()
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public JMenuBar()
Method Detail |
---|
public JMenu add(JMenu c)
c
- menu to add
public void addNotify()
addNotify
in class JComponent
Component.isDisplayable()
,
Component.removeNotify()
public AccessibleContext getAccessibleContext()
JComponent
getAccessibleContext
in interface Accessible
getAccessibleContext
in class JComponent
public Component getComponent()
getComponent
in interface MenuElement
public Component getComponentAtIndex(int i)
i
- index of the component to get
public int getComponentIndex(Component c)
c
- Component to search for
public 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 menu
public int getMenuCount()
public SingleSelectionModel getSelectionModel()
public MenuElement[] getSubElements()
getSubElements
in interface MenuElement
public MenuBarUI getUI()
public String getUIClassID()
getUIClassID
in class JComponent
JComponent.setUI(javax.swing.plaf.ComponentUI)
,
JComponent.updateUI()
public boolean isBorderPainted()
public boolean isSelected()
public void menuSelectionChanged(boolean isIncluded)
menuSelectionChanged
in interface MenuElement
isIncluded
- true if menuBar is included in the selection
and false otherwiseprotected void paintBorder(Graphics g)
paintBorder
in class JComponent
g
- 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 JComponent
public void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager)
processKeyEvent
in interface MenuElement
e
- 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 JComponent
ks
- 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 MenuElement
event
- 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 JComponent
Component.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
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |