JPopupMenu

You can attach a JPopupMenu to any of the following components:
JLabel, all kinds of buttons, JTextArea, JEditorPane, JTextPane, JList, JTable and JTree.
Example 25 Mozilla Mail Client

Because a popup menu is invisible (unless it is triggered), it has no visual representation in the design grid. To keep track of all popup menus, press <M>, this displays an icon and a tooltip for every popup menu as long as the key is pressed.

To attach a popup menu to a component, select 'Attach Popup Menu' from the component's context menu or drag the popup menu icon from the components palette onto the desired component.

To edit a popup menu, select 'Edit Popup Menu Items' from the popup invoker's context menu, this will open the Popup editor which is similar to the Menu editor.

To copy, cut or remove a popup menu, select the appropriate command either from the popup invoker's context menu or from the context menu of the popup component in the project view.

In the 'Edit Popup Menu Properties' dialog you can edit the following properties:
Variable name: Specify a name for the popup menu.
Trigger mode: Decide which gesture makes the popup menu appear on screen.
Popup trigger is the platform dependent way to trigger popup menus, most often by pressing the right mouse button.
Button 1 displays the popup menu after the user pressed the left mouse button, you can decide if it is displayed on mouse released or on mouse pressed.
Always is the combination of the first two options.
Sensitive area: You can restrict the area within which the popup menu is triggered. If the popup menu is triggered, the mouse event will be consumed.
Popup position: Specify where (relative to the invoking component) the popup menu will be displayed.
Pre-display method name: The method to execute before the popup menu is to be displayed. This allows for manipulating the popup menu's items dependent on your application's current state.