javax.swing
public class JPopupMenu extends JComponent implements Accessible, MenuElement
Nested Class Summary | |
---|---|
protected class | JPopupMenu.AccessibleJPopupMenu |
static class | JPopupMenu.Separator
This is the separator that can be used in popup menu. |
Field Summary | |
---|---|
protected SingleSelectionModel | selectionModel SelectionModel that keeps track of menu selection. |
Constructor Summary | |
---|---|
JPopupMenu()
Creates a new JPopupMenu object. | |
JPopupMenu(String label)
Creates a new JPopupMenu with specified label
|
Method Summary | |
---|---|
JMenuItem | add(JMenuItem item)
Adds given menu item to the popup menu
|
JMenuItem | add(String text)
Constructs menu item with a specified label and adds it to
popup menu
|
JMenuItem | add(Action action)
Constructs menu item associated with the specified action
and adds it to the popup menu
|
void | addMenuKeyListener(MenuKeyListener l)
Adds a MenuKeyListener to the popup.
|
void | addPopupMenuListener(PopupMenuListener listener)
Adds popupMenuListener to listen for PopupMenuEvents fired
by the JPopupMenu
|
void | addSeparator()
Adds separator to this popup menu |
protected PropertyChangeListener | createActionChangeListener(JMenuItem item)
Creates PropertyChangeListener that listens to PropertyChangeEvents
occuring in the Action associated with given menu item in this popup menu.
|
protected JMenuItem | createActionComponent(Action action)
Creates new menu item associated with a given action.
|
protected void | firePopupMenuCanceled()
This method calls popupMenuCanceled() of popup menu's PopupMenuListeners.
|
protected void | firePopupMenuWillBecomeInvisible()
This method calls popupMenuWillBecomeInvisible() of popup
menu's PopupMenuListeners. |
protected void | firePopupMenuWillBecomeVisible()
This method calls popupMenuWillBecomeVisible() of popup menu's
PopupMenuListeners. |
AccessibleContext | getAccessibleContext()
DOCUMENT ME!
|
Component | getComponent()
Method of the MenuElement interface. |
Component | getComponentAtIndex(int index)
Returns component located at the specified index in the popup menu
|
int | getComponentIndex(Component component)
Returns index of the specified component in the popup menu
|
static boolean | getDefaultLightWeightPopupEnabled()
Returns flag indicating if newly created JPopupMenu will use
heavyweight or lightweight container to display its menu items
|
Component | getInvoker()
Returns popup menu's invoker.
|
String | getLabel()
Returns label for this popup menu
|
Insets | getMargin()
Returns margin for this popup menu.
|
MenuKeyListener[] | getMenuKeyListeners()
Returns array of getMenuKeyListeners that are listening to JPopupMenu.
|
PopupMenuListener[] | getPopupMenuListeners()
Returns array of PopupMenuListeners that are listening to JPopupMenu
|
SingleSelectionModel | getSelectionModel()
Returns selectionModel used by this popup menu to keep
track of the selection.
|
MenuElement[] | getSubElements()
Return subcomonents of this popup menu. |
PopupMenuUI | getUI()
This method returns the UI used to display the JPopupMenu.
|
String | getUIClassID()
This method returns a name to identify which look and feel class will be
the UI delegate for the menuItem.
|
void | insert(Action action, int index)
Create menu item associated with the given action
and inserts it into the popup menu at the specified index
|
void | insert(Component component, int index)
Insert given component to the popup menu at the
specified index
|
boolean | isBorderPainted()
Checks if this popup menu paints its border.
|
boolean | isLightWeightPopupEnabled()
Returns true if this popup menu will display its menu item in
a lightweight container and false otherwise.
|
boolean | isPopupTrigger(MouseEvent event)
Checks if observing mouse event should trigger popup
menu to show on the screen.
|
boolean | isVisible()
Return visibility of the popup menu
|
void | menuSelectionChanged(boolean changed)
Method of MenuElement Interface. |
void | pack()
This methods sets popup menu's size to its' preferred size. |
protected String | paramString()
A string that describes this JPopupMenu. |
void | processKeyEvent(KeyEvent event, 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 | remove(int index)
Revomes component at the given index from the menu.
|
void | removeMenuKeyListener(MenuKeyListener l)
Removes a MenuKeyListener from the popup.
|
void | removePopupMenuListener(PopupMenuListener listener)
Removes PopupMenuListener from JPopupMenu's list of listeners
|
void | setBorderPainted(boolean painted)
Sets if the border of the popup menu should be
painter or not.
|
static void | setDefaultLightWeightPopupEnabled(boolean enabled)
Sets whether JPopupMenu should use ligthWeight container to
display it menu items by default
|
void | setInvoker(Component component)
Sets popup menu's invoker.
|
void | setLabel(String label)
Sets label for this popup menu. |
void | setLightWeightPopupEnabled(boolean enabled)
DOCUMENT ME!
|
void | setLocation(int x, int y)
Sets location of the popup menu.
|
void | setPopupSize(Dimension size)
Sets size of the popup
|
void | setPopupSize(int width, int height)
Sets size of the popup menu
|
void | setSelected(Component selected)
Selects specified component in this popup menu.
|
void | setSelectionModel(SingleSelectionModel model)
Sets selection model for this popup menu
|
void | setUI(PopupMenuUI ui)
Set the "UI" property of the menu item, which is a look and feel class
responsible for handling popupMenu's input events and painting it.
|
void | setVisible(boolean visible)
Sets visibility property of this popup menu. |
void | show(Component component, int x, int y)
This method displays JPopupMenu on the screen at the specified
location. |
void | updateUI()
This method sets this menuItem's UI to the UIManager's default for the
current look and feel. |
Parameters: label Label for popup menu.
Parameters: item menu item to add to the popup menu
Returns: menu item that was added to the popup menu
Parameters: text label for the menu item to be added
Returns: constructed menu item that was added to the popup menu
Parameters: action Action for the new menu item
Returns: menu item that was added to the menu
Parameters: l - the listener to add.
Parameters: listener PopupMenuListener to add to JPopupMenu
Parameters: item MenuItem
Returns: The PropertyChangeListener
Parameters: action Action used to create new menu item
Returns: new created menu item associated with a given action.
Returns: DOCUMENT ME!
Returns: Returns reference to itself
Deprecated: Replaced by getComponent(int)
Returns component located at the specified index in the popup menuParameters: index index of the component to return
Returns: component located at the specified index in the popup menu
Parameters: component Component to look for
Returns: index of the specified component in the popup menu
Returns: true if JPopupMenu will use lightweight container to display menu items by default, and false otherwise.
Returns: popup menu's invoker
Returns: label for this popup menu
Returns: margin for this popup menu.
Returns: array of getMenuKeyListeners that are listening to JPopupMenu
Returns: Array of PopupMenuListeners that are listening to JPopupMenu
Returns: popup menu's selection model
MenuElement
interface.
Returns: array of menu items belonging to this popup menu
Returns: The UI used to display the JPopupMenu.
Returns: The Look and Feel classID. "PopupMenuUI"
Parameters: action Action for the new menu item index index in the popup menu at which to insert new menu item.
Parameters: component Component to insert index Index at which to insert given component
Returns: true if this popup menu paints its border and false otherwise.
Returns: true if this popup menu will display its menu items in a lightweight container and false otherwise.
Parameters: event MouseEvent to check
Returns: true if the observing mouse event is popup trigger and false otherwise
Returns: true if popup menu is visible on the screen and false otherwise.
Parameters: changed true if this popupMenu is part of current menu hierarchy and false otherwise.
Returns: A string describing this JMenuItem
Parameters: event event forwarded from MenuSelectionManager path path to the menu element from which event was generated manager MenuSelectionManager for the current menu hierarchy
Parameters: event event forwarded from MenuSelectionManager path path to the menu element from which event was generated manager MenuSelectionManager for the current menu hierarchy
Parameters: index index of the component that will be removed in the menu
Parameters: l - the listener to remove.
Parameters: listener PopupMenuListener which needs to be removed
Parameters: painted true if the border should be painted and false otherwise
Parameters: enabled true if JPopupMenu should use lightweight container for displaying its menu items, and false otherwise.
Parameters: component The new invoker of this popup menu
Parameters: label label for this popup menu
Parameters: enabled DOCUMENT ME!
Parameters: x X coordinate of the popup menu's location y Y coordinate of the popup menu's location
Parameters: size Dimensions representing new size of the popup menu
Parameters: width width for the new size height height for the new size
Parameters: selected component to select
Parameters: model new selection model of this popup menu
Parameters: ui The new "UI" property
Parameters: visible true if popup menu will become visible and false otherwise.
Parameters: component Invoker for this popup menu x x-coordinate of the popup menu relative to the specified invoker y y-coordiate of the popup menu relative to the specified invoker