JPopupMenu is used for the
menu that appears when the user selects an item on the menu bar.
It is also used for "pull-right" menu that appears when the
selects a menu item that activates it. Finally, a JPopupMenu
can also be used anywhere else you want a menu to appear. For
example, when the user right-clicks in a specified area.
For information and examples of using popup menus, see How to Use Menus in The Java Tutorial.
Warning
Swing is not thread safe. For more information see Swing's Threading Policy.
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 JavaBeans
has been added to the java.beans package.
Please see java..
| Modifier and Type | Class and Description |
|---|---|
| protected class | JPopupMenu.
This class implements accessibility support for the
|
| private class | |
| public static class | JPopupMenu.
A popup menu-specific separator. |
| Modifier and Type | Field and Description |
|---|---|
| private static final Object | |
| private static final boolean | |
| private static boolean | |
| private int | |
| private int | |
| pack-priv transient Frame | |
| pack-priv transient Component | |
| private String | |
| private boolean | lightWeightPopup
Used to indicate if lightweight popups should be used. |
| private Insets | |
| private boolean | |
| pack-priv transient Popup | |
| pack-priv static boolean | popupPositionFixDisabled
Bug#4425878-Property javax.swing.adjustPopupLocationToFit introduced |
| private PropertyChangeListener | |
| private SingleSelectionModel | |
| private static final boolean | |
| private static final String | |
| private static final boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public | JPopupMenu(String
the string that a UI may use to display as a title
for the popup menu. label)Constructs a |
| Modifier and Type | Method and Description |
|---|---|
| public JMenuItem | |
| public JMenuItem | |
| public JMenuItem | |
| public void | addMenuKeyListener(MenuKeyListener
the l)MenuKeyListener to be addedAdds a |
| public void | |
| public void | |
| pack-priv Point | adjustPopupLocationToFitScreen(int xPosition, int yPosition)
Returns an point which has been adjusted to take into account the desktop bounds, taskbar and multi-monitor configuration. |
| pack-priv boolean | Returns: trueOverrides javax. Always returns true since popups, by definition, should always be on top of all other windows. |
| pack-priv static boolean | |
| protected PropertyChangeListener | Returns: a properly configuredPropertyChangeListenerthe menu item for which to create a listener b)Returns a properly configured |
| protected JMenuItem | Returns: the new menu itemthe a)Action for the menu item to be addedFactory method which creates the |
| private void | fireMenuKeyPressed(MenuKeyEvent
a event)MenuKeyEventNotifies all listeners that have registered interest for notification on this event type. |
| private void | fireMenuKeyReleased(MenuKeyEvent
a event)MenuKeyEventNotifies all listeners that have registered interest for notification on this event type. |
| private void | fireMenuKeyTyped(MenuKeyEvent
a event)MenuKeyEventNotifies all listeners that have registered interest for notification on this event type. |
| protected void | |
| protected void | firePopupMenuWillBecomeInvisible()
Notifies |
| protected void | firePopupMenuWillBecomeVisible()
Notifies |
| public AccessibleContext | Returns: an AccessibleJPopupMenu that serves as the AccessibleContext of this JPopupMenuOverrides java. Implements javax. Gets the AccessibleContext associated with this JPopupMenu. |
| public Component | Returns: thisJPopupMenu objectImplements javax. Returns this |
| public Component | Returns: theComponent at that indexthe index of the component, where 0 is the first i)
Deprecated
replaced by
java.
Returns the component at the specified index. |
| public int | Returns: the index of the component, where 0 is the first; or -1 if the component is not foundthe c)Component to findReturns the index of the specified component. |
| private GraphicsConfiguration | getCurrentGraphicsConfiguration(Point popupLocation)
Tries to find GraphicsConfiguration that contains the mouse cursor position. |
| public static boolean | Returns: the value of thedefaultLightWeightPopupEnabled
propertyGets the |
| private static Frame | |
| public Component | Returns: theComponent in which the popup menu is displayedReturns the component which is the 'invoker' of this popup menu. |
| public String | |
| public Insets | Returns: anInsets object containing the margin values.Returns the margin, in pixels, between the popup menu's border and its containers. |
| private Window | |
| public MenuKeyListener[] | Returns: all of theMenuKeyListeners added or an empty
array if no listeners have been addedReturns an array of all the |
| public PopupMenuListener[] | Returns: all of thePopupMenuListeners added or an empty
array if no listeners have been addedReturns an array of all the |
| pack-priv JPopupMenu | Returns: the topmost grandparentJPopupMenuReturns the popup menu which is at the root of the menu system for this popup menu. |
| public SingleSelectionModel | Returns: theselectionModel propertyReturns the model object that handles single selections. |
| public MenuElement[] | Returns: an array ofMenuElement objectsImplements javax. Returns an array of |
| public PopupMenuUI | Returns: thePopupMenuUI object that renders this componentOverrides javax. Returns the look and feel (L&F) object that renders this component. |
| public String | Returns: the string "PopupMenuUI"Overrides javax. Returns the name of the L&F class that renders this component. |
| public void | |
| public void | |
| public boolean | Returns: true if the border is painted, false otherwiseChecks whether the border should be painted. |
| public boolean | Returns: the value of thelightWeightPopupEnabled propertyGets the |
| private boolean | Returns: true if this menu is a standalone popup menu, otherwise falseReturns true if the popup menu is a standalone popup menu
rather than the submenu of a |
| public boolean | Returns: true if the mouse event is a popup triggera e)MouseEventReturns true if the |
| pack-priv boolean | Returns: true ifpopupa popup)JPopupMenuExamines the list of menu items to determine whether
|
| public boolean | isVisible()
Overrides java. Returns true if the popup menu is visible (currently being displayed). |
| public void | menuSelectionChanged(boolean
true if this menu is active, false if
it is not isIncluded)Implements javax. Messaged when the menubar selection changes to activate or deactivate this menu. |
| public void | |
| protected void | paintBorder(Graphics
the g)Graphics objectOverrides javax. Paints the popup menu's border if the |
| protected String | Returns: a string representation of thisJPopupMenu.Overrides javax. Returns a string representation of this |
| protected void | processFocusEvent(FocusEvent evt)
Overrides java. Processes focus events occurring on this component by
dispatching them to any registered
|
| protected void | processKeyEvent(KeyEvent
the key event to be processed evt)Overrides javax. Processes key stroke events such as mnemonics and accelerators. |
| public void | processKeyEvent(KeyEvent
a e, MenuElement[] KeyEventthe path, MenuSelectionManager MenuElement path arraythe manager)MenuSelectionManagerImplements javax. Processes a key event forwarded from the
|
| private void | |
| public void | processMouseEvent(MouseEvent event, MenuElement[] path, MenuSelectionManager manager)
Implements javax. This method is required to conform to the
|
| private void | readObject(ObjectInputStream s)
Hides javax. We use the |
| public void | remove(int
the position of the item to be removed pos)Overrides java. Removes the component at the specified index from this popup menu. |
| public void | removeMenuKeyListener(MenuKeyListener
the l)MenuKeyListener to be removedRemoves a |
| public void | removePopupMenuListener(PopupMenuListener
the l)PopupMenuListener to removeRemoves a |
| public void | setBorderPainted(boolean
if true, the border is painted. b)Sets whether the border should be painted. |
| public static void | setDefaultLightWeightPopupEnabled(boolean
true if popups can be lightweight,
otherwise falseSets the default value of the |
| public void | setInvoker(Component
the invoker)Component in which the popup
menu is displayedSets the invoker of this popup menu -- the component in which the popup menu is to be displayed. |
| public void | |
| public void | setLightWeightPopupEnabled(boolean
false to disable lightweight popupsSets the value of the |
| public void | setLocation(int
the x coordinate of the popup's new position
in the screen's coordinate space x, int the y coordinate of the popup's new position
in the screen's coordinate space y)Overrides java. Sets the location of the upper left corner of the popup menu using x, y coordinates. |
| public void | setPopupSize(Dimension
the d)Dimension specifying the new size
of this component.Sets the size of the Popup window using a |
| public void | setPopupSize(int
the new width of the Popup in pixels width, int the new height of the Popup in pixels height)Sets the size of the Popup window to the specified width and height. |
| public void | setSelected(Component
the sel)Component to selectSets the currently selected component, This will result in a change to the selection model. |
| public void | setSelectionModel(SingleSelectionModel
the new model)SingleSelectionModelSets the model object to handle single selections. |
| public void | |
| public void | setVisible(boolean
true to make the popup visible, or false to
hide it b)Overrides javax. Sets the visibility of the popup menu. |
| public void | show(Component
the component in whose space the popup menu is to appear invoker, int the x coordinate in invoker's coordinate space at which
the popup menu is to be displayed x, int the y coordinate in invoker's coordinate space at which
the popup menu is to be displayed y)Displays the popup menu at the position x,y in the coordinate space of the component invoker. |
| private void | |
| public void | updateUI()
Overrides javax. Resets the UI property to a value from the current look and feel. |
| private void | writeObject(ObjectOutputStream s)
Hides javax. Before writing a |