An implementation of a popup menu -- a small window that pops up and displays a series of choices. A 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 XMLEncoder.
An implementation of a popup menu -- a small window that pops up and displays a series of choices. A 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 XMLEncoder.
(*get-default-light-weight-popup-enabled?)
Gets the defaultLightWeightPopupEnabled property, which by default is true.
returns: the value of the defaultLightWeightPopupEnabled
property - boolean
Gets the defaultLightWeightPopupEnabled property, which by default is true. returns: the value of the defaultLightWeightPopupEnabled property - `boolean`
(*set-default-light-weight-popup-enabled a-flag)
Sets the default value of the lightWeightPopupEnabled property.
a-flag - true if popups can be lightweight, otherwise false - boolean
Sets the default value of the lightWeightPopupEnabled property. a-flag - true if popups can be lightweight, otherwise false - `boolean`
(->j-popup-menu)
(->j-popup-menu label)
Constructor.
Constructs a JPopupMenu with the specified title.
label - the string that a UI may use to display as a title for the popup menu. - java.lang.String
Constructor. Constructs a JPopupMenu with the specified title. label - the string that a UI may use to display as a title for the popup menu. - `java.lang.String`
(add this menu-item)
Appends the specified menu item to the end of this menu.
menu-item - the JMenuItem to add - javax.swing.JMenuItem
returns: the JMenuItem added - javax.swing.JMenuItem
Appends the specified menu item to the end of this menu. menu-item - the JMenuItem to add - `javax.swing.JMenuItem` returns: the JMenuItem added - `javax.swing.JMenuItem`
(add-menu-key-listener this l)
Adds a MenuKeyListener to the popup menu.
l - the MenuKeyListener to be added - javax.swing.event.MenuKeyListener
Adds a MenuKeyListener to the popup menu. l - the MenuKeyListener to be added - `javax.swing.event.MenuKeyListener`
(add-popup-menu-listener this l)
Adds a PopupMenu listener.
l - the PopupMenuListener to add - javax.swing.event.PopupMenuListener
Adds a PopupMenu listener. l - the PopupMenuListener to add - `javax.swing.event.PopupMenuListener`
(add-separator this)
Appends a new separator at the end of the menu.
Appends a new separator at the end of the menu.
(border-painted? this)
Checks whether the border should be painted.
returns: true if the border is painted, false otherwise - boolean
Checks whether the border should be painted. returns: true if the border is painted, false otherwise - `boolean`
(get-accessible-context this)
Gets the AccessibleContext associated with this JPopupMenu. For JPopupMenus, the AccessibleContext takes the form of an AccessibleJPopupMenu. A new AccessibleJPopupMenu instance is created if necessary.
returns: an AccessibleJPopupMenu that serves as the
AccessibleContext of this JPopupMenu - javax.accessibility.AccessibleContext
Gets the AccessibleContext associated with this JPopupMenu. For JPopupMenus, the AccessibleContext takes the form of an AccessibleJPopupMenu. A new AccessibleJPopupMenu instance is created if necessary. returns: an AccessibleJPopupMenu that serves as the AccessibleContext of this JPopupMenu - `javax.accessibility.AccessibleContext`
(get-component this)
Returns this JPopupMenu component.
returns: this JPopupMenu object - java.awt.Component
Returns this JPopupMenu component. returns: this JPopupMenu object - `java.awt.Component`
(get-component-at-index this i)
Deprecated. replaced by Container.getComponent(int)
i - the index of the component, where 0 is the first - int
returns: the Component at that index - java.awt.Component
Deprecated. replaced by Container.getComponent(int) i - the index of the component, where 0 is the first - `int` returns: the Component at that index - `java.awt.Component`
(get-component-index this c)
Returns the index of the specified component.
c - the Component to find - java.awt.Component
returns: the index of the component, where 0 is the first;
or -1 if the component is not found - int
Returns the index of the specified component. c - the Component to find - `java.awt.Component` returns: the index of the component, where 0 is the first; or -1 if the component is not found - `int`
(get-invoker this)
Returns the component which is the 'invoker' of this popup menu.
returns: the Component in which the popup menu is displayed - java.awt.Component
Returns the component which is the 'invoker' of this popup menu. returns: the Component in which the popup menu is displayed - `java.awt.Component`
(get-label this)
Returns the popup menu's label
returns: a string containing the popup menu's label - java.lang.String
Returns the popup menu's label returns: a string containing the popup menu's label - `java.lang.String`
(get-margin this)
Returns the margin, in pixels, between the popup menu's border and its containers.
returns: an Insets object containing the margin values. - java.awt.Insets
Returns the margin, in pixels, between the popup menu's border and its containers. returns: an Insets object containing the margin values. - `java.awt.Insets`
(get-menu-key-listeners this)
Returns an array of all the MenuKeyListeners added to this JPopupMenu with addMenuKeyListener().
returns: all of the MenuKeyListeners added or an empty
array if no listeners have been added - javax.swing.event.MenuKeyListener[]
Returns an array of all the MenuKeyListeners added to this JPopupMenu with addMenuKeyListener(). returns: all of the MenuKeyListeners added or an empty array if no listeners have been added - `javax.swing.event.MenuKeyListener[]`
(get-popup-menu-listeners this)
Returns an array of all the PopupMenuListeners added to this JMenuItem with addPopupMenuListener().
returns: all of the PopupMenuListeners added or an empty
array if no listeners have been added - javax.swing.event.PopupMenuListener[]
Returns an array of all the PopupMenuListeners added to this JMenuItem with addPopupMenuListener(). returns: all of the PopupMenuListeners added or an empty array if no listeners have been added - `javax.swing.event.PopupMenuListener[]`
(get-selection-model this)
Returns the model object that handles single selections.
returns: the selectionModel property - javax.swing.SingleSelectionModel
Returns the model object that handles single selections. returns: the selectionModel property - `javax.swing.SingleSelectionModel`
(get-sub-elements this)
Returns an array of MenuElements containing the submenu for this menu component. It will only return items conforming to the JMenuElement interface. If popup menu is null returns an empty array. This method is required to conform to the MenuElement interface.
returns: an array of MenuElement objects - javax.swing.MenuElement[]
Returns an array of MenuElements containing the submenu for this menu component. It will only return items conforming to the JMenuElement interface. If popup menu is null returns an empty array. This method is required to conform to the MenuElement interface. returns: an array of MenuElement objects - `javax.swing.MenuElement[]`
(get-ui this)
Returns the look and feel (L&F) object that renders this component.
returns: the PopupMenuUI object that renders this component - javax.swing.plaf.PopupMenuUI
Returns the look and feel (L&F) object that renders this component. returns: the PopupMenuUI object that renders this component - `javax.swing.plaf.PopupMenuUI`
(get-ui-class-id this)
Returns the name of the L&F class that renders this component.
returns: the string "PopupMenuUI" - java.lang.String
Returns the name of the L&F class that renders this component. returns: the string "PopupMenuUI" - `java.lang.String`
(insert this a index)
Inserts a menu item for the specified Action object at a given position.
a - the Action object to insert - javax.swing.Action
index - specifies the position at which to insert the Action, where 0 is the first - int
throws: java.lang.IllegalArgumentException - if index < 0
Inserts a menu item for the specified Action object at a given position. a - the Action object to insert - `javax.swing.Action` index - specifies the position at which to insert the Action, where 0 is the first - `int` throws: java.lang.IllegalArgumentException - if index < 0
(light-weight-popup-enabled? this)
Gets the lightWeightPopupEnabled property.
returns: the value of the lightWeightPopupEnabled property - boolean
Gets the lightWeightPopupEnabled property. returns: the value of the lightWeightPopupEnabled property - `boolean`
(menu-selection-changed this is-included)
Messaged when the menubar selection changes to activate or deactivate this menu. This implements the javax.swing.MenuElement interface. Overrides MenuElement.menuSelectionChanged.
is-included - true if this menu is active, false if it is not - boolean
Messaged when the menubar selection changes to activate or deactivate this menu. This implements the javax.swing.MenuElement interface. Overrides MenuElement.menuSelectionChanged. is-included - true if this menu is active, false if it is not - `boolean`
(pack this)
Lays out the container so that it uses the minimum space needed to display its contents.
Lays out the container so that it uses the minimum space needed to display its contents.
(popup-trigger? this e)
Returns true if the MouseEvent is considered a popup trigger by the JPopupMenu's currently installed UI.
e - java.awt.event.MouseEvent
returns: true if the mouse event is a popup trigger - boolean
Returns true if the MouseEvent is considered a popup trigger by the JPopupMenu's currently installed UI. e - `java.awt.event.MouseEvent` returns: true if the mouse event is a popup trigger - `boolean`
(process-key-event this e path manager)
Processes a key event forwarded from the MenuSelectionManager and changes the menu selection, if necessary, by using MenuSelectionManager's API.
Note: you do not have to forward the event to sub-components. This is done automatically by the MenuSelectionManager.
e - a KeyEvent - java.awt.event.KeyEvent
path - the MenuElement path array - javax.swing.MenuElement[]
manager - the MenuSelectionManager - javax.swing.MenuSelectionManager
Processes a key event forwarded from the MenuSelectionManager and changes the menu selection, if necessary, by using MenuSelectionManager's API. Note: you do not have to forward the event to sub-components. This is done automatically by the MenuSelectionManager. e - a KeyEvent - `java.awt.event.KeyEvent` path - the MenuElement path array - `javax.swing.MenuElement[]` manager - the MenuSelectionManager - `javax.swing.MenuSelectionManager`
(process-mouse-event this event path manager)
This method is required to conform to the MenuElement interface, but it not implemented.
event - java.awt.event.MouseEvent
path - javax.swing.MenuElement[]
manager - javax.swing.MenuSelectionManager
This method is required to conform to the MenuElement interface, but it not implemented. event - `java.awt.event.MouseEvent` path - `javax.swing.MenuElement[]` manager - `javax.swing.MenuSelectionManager`
(remove this pos)
Removes the component at the specified index from this popup menu.
pos - the position of the item to be removed - int
throws: java.lang.IllegalArgumentException - if the value of pos < 0, or if the value of pos is greater than the number of items
Removes the component at the specified index from this popup menu. pos - the position of the item to be removed - `int` throws: java.lang.IllegalArgumentException - if the value of pos < 0, or if the value of pos is greater than the number of items
(remove-menu-key-listener this l)
Removes a MenuKeyListener from the popup menu.
l - the MenuKeyListener to be removed - javax.swing.event.MenuKeyListener
Removes a MenuKeyListener from the popup menu. l - the MenuKeyListener to be removed - `javax.swing.event.MenuKeyListener`
(remove-popup-menu-listener this l)
Removes a PopupMenu listener.
l - the PopupMenuListener to remove - javax.swing.event.PopupMenuListener
Removes a PopupMenu listener. l - the PopupMenuListener to remove - `javax.swing.event.PopupMenuListener`
(set-border-painted this b)
Sets whether the border should be painted.
b - if true, the border is painted. - boolean
Sets whether the border should be painted. b - if true, the border is painted. - `boolean`
(set-invoker this invoker)
Sets the invoker of this popup menu -- the component in which the popup menu menu is to be displayed.
invoker - the Component in which the popup menu is displayed - java.awt.Component
Sets the invoker of this popup menu -- the component in which the popup menu menu is to be displayed. invoker - the Component in which the popup menu is displayed - `java.awt.Component`
(set-label this label)
Sets the popup menu's label. Different look and feels may choose to display or not display this.
label - a string specifying the label for the popup menu - java.lang.String
Sets the popup menu's label. Different look and feels may choose to display or not display this. label - a string specifying the label for the popup menu - `java.lang.String`
(set-light-weight-popup-enabled this a-flag)
Sets the value of the lightWeightPopupEnabled property, which by default is true. By default, when a look and feel displays a popup, it can choose to use a lightweight (all-Java) popup. Lightweight popup windows are more efficient than heavyweight (native peer) windows, but lightweight and heavyweight components do not mix well in a GUI. If your application mixes lightweight and heavyweight components, you should disable lightweight popups. Some look and feels might always use heavyweight popups, no matter what the value of this property.
a-flag - false to disable lightweight popups - boolean
Sets the value of the lightWeightPopupEnabled property, which by default is true. By default, when a look and feel displays a popup, it can choose to use a lightweight (all-Java) popup. Lightweight popup windows are more efficient than heavyweight (native peer) windows, but lightweight and heavyweight components do not mix well in a GUI. If your application mixes lightweight and heavyweight components, you should disable lightweight popups. Some look and feels might always use heavyweight popups, no matter what the value of this property. a-flag - false to disable lightweight popups - `boolean`
(set-location this x y)
Sets the location of the upper left corner of the popup menu using x, y coordinates.
The method changes the geometry-related data. Therefore, the native windowing system may ignore such requests, or it may modify the requested data, so that the JPopupMenu object is placed and sized in a way that corresponds closely to the desktop settings.
x - the x coordinate of the popup's new position in the screen's coordinate space - int
y - the y coordinate of the popup's new position in the screen's coordinate space - int
Sets the location of the upper left corner of the popup menu using x, y coordinates. The method changes the geometry-related data. Therefore, the native windowing system may ignore such requests, or it may modify the requested data, so that the JPopupMenu object is placed and sized in a way that corresponds closely to the desktop settings. x - the x coordinate of the popup's new position in the screen's coordinate space - `int` y - the y coordinate of the popup's new position in the screen's coordinate space - `int`
(set-popup-size this d)
(set-popup-size this width height)
Sets the size of the Popup window to the specified width and height. This is equivalent to setPreferredSize(new Dimension(width, height)).
width - the new width of the Popup in pixels - int
height - the new height of the Popup in pixels - int
Sets the size of the Popup window to the specified width and height. This is equivalent to setPreferredSize(new Dimension(width, height)). width - the new width of the Popup in pixels - `int` height - the new height of the Popup in pixels - `int`
(set-selected this sel)
Sets the currently selected component, This will result in a change to the selection model.
sel - the Component to select - java.awt.Component
Sets the currently selected component, This will result in a change to the selection model. sel - the Component to select - `java.awt.Component`
(set-selection-model this model)
Sets the model object to handle single selections.
model - the new SingleSelectionModel - javax.swing.SingleSelectionModel
Sets the model object to handle single selections. model - the new SingleSelectionModel - `javax.swing.SingleSelectionModel`
(set-ui this ui)
Sets the L&F object that renders this component.
ui - the new PopupMenuUI L&F object - javax.swing.plaf.PopupMenuUI
Sets the L&F object that renders this component. ui - the new PopupMenuUI L&F object - `javax.swing.plaf.PopupMenuUI`
(set-visible this b)
Sets the visibility of the popup menu.
b - true to make the popup visible, or false to hide it - boolean
Sets the visibility of the popup menu. b - true to make the popup visible, or false to hide it - `boolean`
(show this invoker x y)
Displays the popup menu at the position x,y in the coordinate space of the component invoker.
invoker - the component in whose space the popup menu is to appear - java.awt.Component
x - the x coordinate in invoker's coordinate space at which the popup menu is to be displayed - int
y - the y coordinate in invoker's coordinate space at which the popup menu is to be displayed - int
Displays the popup menu at the position x,y in the coordinate space of the component invoker. invoker - the component in whose space the popup menu is to appear - `java.awt.Component` x - the x coordinate in invoker's coordinate space at which the popup menu is to be displayed - `int` y - the y coordinate in invoker's coordinate space at which the popup menu is to be displayed - `int`
(update-ui this)
Resets the UI property to a value from the current look and feel.
Resets the UI property to a value from the current look and feel.
(visible? this)
Returns true if the popup menu is visible (currently being displayed).
returns: true if the component is visible,
false otherwise - boolean
Returns true if the popup menu is visible (currently being displayed). returns: true if the component is visible, false otherwise - `boolean`
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close