Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JMenuBar
Nested Class Summary | |
protected class |
|
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 | |
TOOL_TIP_TEXT_KEY , UNDEFINED_CONDITION , WHEN_ANCESTOR_OF_FOCUSED_COMPONENT , WHEN_FOCUSED , WHEN_IN_FOCUSED_WINDOW , accessibleContext , listenerList , ui |
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 | |
|
Method Summary | |
JMenu | |
void |
|
AccessibleContext |
|
Component |
|
Component |
|
int |
|
JMenu |
|
Insets |
|
JMenu |
|
int |
|
SingleSelectionModel |
|
MenuElement[] |
|
MenuBarUI |
|
String |
|
boolean |
|
boolean |
|
void |
|
protected void |
|
protected String |
|
protected boolean |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void | |
void |
|
void |
|
void | |
void |
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public JMenu add(JMenu c)
Adds menu to the menu bar
- Parameters:
c
- menu to add
- Returns:
- reference to the added menu
public void addNotify()
This method overrides addNotify() in the Container to register this menu bar with the current keyboard manager.
- Overrides:
- addNotify in interface JComponent
public AccessibleContext getAccessibleContext()
If a component supports the Accessibility API then this method should not returnnull
. Only classes which must extend an accessible class, but must not itself be accessible, may return null.
- Specified by:
- getAccessibleContext in interface Accessible
- Overrides:
- getAccessibleContext in interface JComponent
- Returns:
- the context associated with this accessible object
public Component getComponent()
Returns reference to this menu bar
- Specified by:
- getComponent in interface MenuElement
- Returns:
- reference to this menu bar
public Component getComponentAtIndex(int i)
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.
public int getComponentIndex(Component c)
Returns index of the specified component
- Parameters:
c
- Component to search for
- Returns:
- index of the specified component. -1 is returned if specified component doesnt' exist in the menu bar.
public JMenu getHelpMenu()
This method is not implemented and will throw anError
if called.
- Returns:
- This method never returns anything, it throws an exception.
public Insets getMargin()
Returns the margin between the menu bar's border and its menus. If the margin isnull
, this method returnsnew Insets(0, 0, 0, 0)
.
- Returns:
- The margin (never
null
).
- See Also:
setMargin(Insets)
public JMenu getMenu(int index)
Return menu at the specified index. If component at the specified index is not a menu, then null is returned.
- Parameters:
index
- index to look for the menu
- Returns:
- menu at specified index, or null if menu doesn't exist at the specified index.
public int getMenuCount()
Returns number of menu's in this menu bar
- Returns:
- number of menu's in this menu bar
public SingleSelectionModel getSelectionModel()
Returns selection model for this menu bar. SelectionModel keeps track of the selected menu in the menu bar. Whenever selected property of selectionModel changes, the ChangeEvent will be fired its ChangeListeners.
- Returns:
- selection model for this menu bar.
public MenuElement[] getSubElements()
Method of MenuElement interface. It returns subcomponents of the menu bar, which are all the menues that it contains.
- Specified by:
- getSubElements in interface MenuElement
- Returns:
- MenuElement[] array containing menues in this menu bar
public 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.
- Returns:
- The current "UI" property
public String getUIClassID()
This method returns a name to identify which look and feel class will be the UI delegate for the menu bar.
- Overrides:
- getUIClassID in interface JComponent
- Returns:
- The Look and Feel classID. "MenuBarUI"
public boolean isBorderPainted()
Returns true if menu bar paints its border and false otherwise
- Returns:
- true if menu bar paints its border and false otherwise
public boolean isSelected()
Returns true if some menu in menu bar is selected.
- Returns:
- true if some menu in menu bar is selected and false otherwise
public void menuSelectionChanged(boolean isIncluded)
This method does nothing by default. This method is need for the MenuElement interface to be implemented.
- Specified by:
- menuSelectionChanged in interface MenuElement
- Parameters:
isIncluded
- true if menuBar is included in the selection and false otherwise
protected void paintBorder(Graphics g)
Paints border of the menu bar, if its borderPainted property is set to true.
- Overrides:
- paintBorder in interface JComponent
- Parameters:
g
- The graphics context with which to paint the border
protected String paramString()
A string that describes this JMenuBar. Normally only used for debugging.
- Overrides:
- paramString in interface JComponent
- Returns:
- A string describing 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.
- Overrides:
- processKeyBinding in interface JComponent
- Parameters:
ks
- the KeyStroke for the evente
- the KeyEvent for the eventcondition
- the focus condition for the bindingpressed
- true if the key is pressed
public void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager)
Process key events forwarded from MenuSelectionManager. This method doesn't do anything. It is here to conform to the MenuElement interface.
- Specified by:
- processKeyEvent in interface MenuElement
- Parameters:
e
- event forwarded from MenuSelectionManagerpath
- path to the menu element from which event was generatedmanager
- MenuSelectionManager for the current menu hierarchy
public void processMouseEvent(MouseEvent event, MenuElement[] path, MenuSelectionManager manager)
Process mouse events forwarded from MenuSelectionManager. This method doesn't do anything. It is here to conform to the MenuElement interface.
- Specified by:
- processMouseEvent in interface MenuElement
- Parameters:
event
- event forwarded from MenuSelectionManagerpath
- path to the menu element from which event was generatedmanager
- MenuSelectionManager for the current menu hierarchy
public void removeNotify()
This method overrides removeNotify() in the Container to unregister this menu bar from the current keyboard manager.
- Overrides:
- removeNotify in interface JComponent
public void setBorderPainted(boolean b)
Sets painting status of the border. If 'b' is true then menu bar's border will be painted, and it will not be painted otherwise.
- Parameters:
b
- indicates if menu bar's border should be painted.
public void setHelpMenu(JMenu menu)
Sets help menu for this menu bar
- Parameters:
menu
- help menu
public 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').
- Parameters:
m
- the margin (null
permitted).
- See Also:
getMargin()
public void setSelected(Component sel)
Changes menu bar's selection to the specified menu. This method updates selected index of menu bar's selection model, which results in a model firing change event.
- Parameters:
sel
- menu to select
public void setSelectionModel(SingleSelectionModel model)
Sets menuBar's selection model to the one specified
- Parameters:
model
- SingleSelectionModel that needs to be set for this menu bar
public 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.
- Parameters:
ui
- The new "UI" property
public void updateUI()
Set the "UI" property to a class constructed, via theUIManager
, from the current look and feel.
- Overrides:
- updateUI in interface JComponent