Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
Nested Class Summary | |
protected class |
|
protected class |
Nested classes/interfaces inherited from class javax.swing.JMenuItem | |
JMenuItem.AccessibleJMenuItem |
Nested classes/interfaces inherited from class javax.swing.AbstractButton | |
AbstractButton.AccessibleAbstractButton , AbstractButton.ButtonChangeListener |
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 | |
protected JMenu.WinListener |
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 |
Fields inherited from interface javax.swing.SwingConstants | |
BOTTOM , CENTER , EAST , HORIZONTAL , LEADING , LEFT , NEXT , NORTH , NORTH_EAST , NORTH_WEST , PREVIOUS , RIGHT , SOUTH , SOUTH_EAST , SOUTH_WEST , TOP , TRAILING , VERTICAL , WEST |
Constructor Summary | |
| |
Method Summary | |
Component | |
Component | |
JMenuItem | |
JMenuItem | |
JMenuItem | |
void |
|
void |
|
protected PropertyChangeListener |
|
protected JMenuItem |
|
protected JMenu.WinListener |
|
void |
|
protected void |
|
protected void |
|
protected void |
|
AccessibleContext |
|
Component | |
int |
|
JMenuItem |
|
int |
|
Component |
|
int |
|
Component[] |
|
MenuListener[] |
|
JPopupMenu |
|
protected Point |
|
MenuElement[] |
|
String |
|
void | |
JMenuItem | |
JMenuItem | |
void |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
void |
|
protected String |
|
protected void |
|
void |
|
void | |
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(String text)
Creates a newJMenu
with the specified label.
- Parameters:
text
- label for this menu
public JMenu(String text, boolean tearoff)
Creates a newJMenu
with specified label and an option for this menu to be tear-off menu.
- Parameters:
text
- label for this menutearoff
- true if this menu should be tear-off and false otherwise
public Component add(Component component)
Adds specified component to this menu.
- Parameters:
component
- Component to add to this menu
- Returns:
- Component that was added
public Component add(Component component, int index)
Adds specified component to this menu at the given index
- Parameters:
component
- Component to addindex
- Position of this menu item in the menu
- Returns:
- Component that was added
public JMenuItem add(String text)
Adds JMenuItem constructed with the specified label to this menu
- Parameters:
text
- label for the menu item that will be added
- Returns:
- Menu Item that was added to this menu
public JMenuItem add(Action action)
Adds JMenuItem constructed using properties from specified action.
- Parameters:
action
- action to construct the menu item with
- Returns:
- Menu Item that was added to this menu
public JMenuItem add(JMenuItem item)
Adds specified menu item to this menu
- Parameters:
item
- Menu item to add to this menu
- Returns:
- Menu item that was added
public void addMenuListener(MenuListener listener)
Adds MenuListener to the menu
- Parameters:
listener
- MenuListener to add
protected PropertyChangeListener createActionChangeListener(JMenuItem item)
Creates ActionChangeListener to listen for PropertyChangeEvents occuring in the action that is associated with this menu
- Parameters:
item
- menu that contains action to listen to
- Returns:
- The PropertyChangeListener
protected JMenuItem createActionComponent(Action action)
Creates and returns JMenuItem associated with the given action
- Parameters:
action
- Action to use for creation of JMenuItem
- Returns:
- JMenuItem that was creted with given action
protected JMenu.WinListener createWinListener(JPopupMenu popup)
Creates WinListener that listens to the menu;s popup menu.
- Parameters:
popup
- JPopupMenu to listen to
- Returns:
- The WinListener
public void doClick(int time)
Programatically performs click
- Overrides:
- doClick in interface AbstractButton
- Parameters:
time
- Number of milliseconds for which this menu stays pressed
protected void fireMenuCanceled()
This method fires MenuEvents to all menu's MenuListeners. In this case menuSelected() method of MenuListeners is called to indicated that the menu was cancelled. The menu is cancelled when it's popup menu is close without selection.
protected void fireMenuDeselected()
This method fires MenuEvents to all menu's MenuListeners. In this case menuDeselected() method of MenuListeners is called to indicated that the menu was deselected.
protected void fireMenuSelected()
This method fires MenuEvents to all menu's MenuListeners. In this case menuSelected() method of MenuListeners is called to indicated that the menu was selected.
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 JMenuItem
- Returns:
- the context associated with this accessible object
public Component getComponent()
- Specified by:
- getComponent in interface MenuElement
- Overrides:
- getComponent in interface JMenuItem
- Returns:
- Returns reference to itself
public int getDelay()
Returns delay property.
- Returns:
- delay property, indicating number of milliseconds before popup menu associated with the menu appears or disappears after menu was selected or deselected respectively
public JMenuItem getItem(int index)
Returns menu item located at the specified index in the menu
- Parameters:
index
- Index at which to look for the menu item
- Returns:
- menu item located at the specified index in the menu
public int getItemCount()
Returns number of items in the menu including separators.
- Returns:
- number of items in the menu
- See Also:
getMenuComponentCount()
public Component getMenuComponent(int index)
Returns menu component located at the givent index in the menu
- Parameters:
index
- index at which to get the menu component in the menu
- Returns:
- Menu Component located in the menu at the specified index
public int getMenuComponentCount()
Returns number of menu components in this menu
- Returns:
- number of menu components in this menu
public Component[] getMenuComponents()
Return components belonging to this menu
- Returns:
- components belonging to this menu
public MenuListener[] getMenuListeners()
Returns all registeredMenuListener
objects.
- Returns:
- an array of listeners
- Since:
- 1.4
public JPopupMenu getPopupMenu()
Returns popup menu associated with the menu.
- Returns:
- popup menu associated with the menu.
protected Point getPopupMenuOrigin()
Returns origin point of the popup menu. This takes the screen bounds into account and places the popup where it fits best.
- Returns:
- the origin of the popup menu
public MenuElement[] getSubElements()
Method of MenuElement interface. Returns sub components of this menu.
- Specified by:
- getSubElements in interface MenuElement
- Overrides:
- getSubElements in interface JMenuItem
- Returns:
- array containing popupMenu that is associated with this menu
public String getUIClassID()
This method returns a name to identify which look and feel class will be the UI delegate for the menu.
- Overrides:
- getUIClassID in interface JMenuItem
- Returns:
- The Look and Feel classID. "MenuUI"
public void insert(String text, int index)
Creates JMenuItem with the specified text and inserts it in the at the specified index
- Parameters:
text
- label for the new menu itemindex
- index at which to insert newly created menu item.
public JMenuItem insert(Action action, int index)
Creates JMenuItem with the associated action and inserts it to the menu at the specified index. IllegalArgumentException is thrown if index is less than 0
- Parameters:
action
- Action for the new menu itemindex
- index at which to insert newly created menu item.
- Returns:
- Menu item that was added to the menu
public JMenuItem insert(JMenuItem item, int index)
Creates JMenuItem with the specified text and inserts it in the at the specified index. IllegalArgumentException is thrown if index is less than 0
- Parameters:
item
- menu item to insertindex
- index at which to insert menu item.
- Returns:
- Menu item that was added to the menu
public void insertSeparator(int index)
Inserts separator in the menu at the specified index.
- Parameters:
index
- Index at which separator should be inserted
public boolean isMenuComponent(Component component)
Checks if given component exists in this menu. The submenus of this menu are checked as well
- Parameters:
component
- Component to look for
- Returns:
- true if the given component exists in this menu, and false otherwise
public boolean isPopupMenuVisible()
Checks if PopupMenu associated with this menu is visible
- Returns:
- true if the popup associated with this menu is currently visible on the screen and false otherwise.
public boolean isSelected()
Returns true if the menu is selected and false otherwise
- Overrides:
- isSelected in interface AbstractButton
- Returns:
- true if the menu is selected and false otherwise
public boolean isTearOff()
Checks if this menu is a tear-off menu.
- Returns:
- true if this menu is a tear-off menu and false otherwise
public boolean isTopLevelMenu()
Checks if this menu is a top level menu. The menu is top level menu if it is inside the menu bar. While if the menu inside some other menu, it is considered to be a pull-right menu.
- Returns:
- true if this menu is top level menu, and false otherwise
public void menuSelectionChanged(boolean changed)
Method of the MenuElementInterface. It reacts to the selection changes in the menu. If this menu was selected, then it displayes popup menu associated with it and if this menu was deselected it hides the popup menu.
- Specified by:
- menuSelectionChanged in interface MenuElement
- Overrides:
- menuSelectionChanged in interface JMenuItem
- Parameters:
changed
- true if the menu was selected and false otherwise
protected String paramString()
A string that describes this JMenu. Normally only used for debugging.
- Overrides:
- paramString in interface JMenuItem
- Returns:
- A string describing this JMenu
protected void processKeyEvent(KeyEvent event)
This method process KeyEvent occuring when the menu is visible
- Overrides:
- processKeyEvent in interface JComponent
- Parameters:
event
- The KeyEvent
public void remove(int index)
Removes component at the specified index from this menu
- Parameters:
index
- Position of the component that needs to be removed in the menu
public void remove(Component component)
Removes given component from this menu.
- Parameters:
component
- Component to remove
public void remove(JMenuItem item)
Removes given menu item from this menu. Nothing happens if this menu doesn't contain specified menu item.
- Parameters:
item
- Menu Item which needs to be removed
public void removeMenuListener(MenuListener listener)
Removes MenuListener from the menu
- Parameters:
listener
- MenuListener to remove
public void setAccelerator(KeyStroke keystroke)
This method is overriden with empty implementation, s.t the accelerator couldn't be set for the menu. The mnemonic should be used for the menu instead.
- Overrides:
- setAccelerator in interface JMenuItem
- Parameters:
keystroke
- accelerator for this menu
public void setDelay(int delay)
Sets delay property for this menu. If given time for the delay property is negative, then IllegalArgumentException is thrown
- Parameters:
delay
- number of milliseconds before popup menu associated with the menu appears or disappears after menu was selected or deselected respectively
public void setMenuLocation(int x, int y)
Sets location at which popup menu should be displayed The location given is relative to this menu item
- Parameters:
x
- x-coordinate of the menu locationy
- y-coordinate of the menu location
public void setModel(ButtonModel model)
Sets model for this menu.
- Overrides:
- setModel in interface AbstractButton
- Parameters:
model
- model to set
public void setPopupMenuVisible(boolean popup)
Sets popup menu visibility
- Parameters:
popup
- true if popup should be visible and false otherwise
public void setSelected(boolean selected)
Changes this menu selected state if selected is true and false otherwise This method fires menuEvents to menu's registered listeners.
- Overrides:
- setSelected in interface AbstractButton
- Parameters:
selected
- true if the menu should be selected and false otherwise