Java: Popup Menus
A popup menu is an instance of the JPopupMenu class, which is very similar to the regular JMenu class: add JMenuItems to it. The menu item listeners are called as usual.
As of Java 5 you can add a popup menu to some components
by calling the setComponentPopupMenu(...)
method.
Altho the method is defined for JComponent and JPanel, it apparently does
nothing, thereby rendering it's usage for these important graphics base
classes useless. Whether this is a bug or a "design feature" is not
known to me.
Older versions require you to add a mouse listener for a component, and when the appropriate mouse event occurs, display the popup menu. This was awkward and the the Java implementors should be applauded for fixing this in Java 5.
Triggered by a right click in a graphics area
The typical user-interface situation for producing a pop-up menu is when the user right-clicks in a user-drawn component.
JPopupMenu.Separator
One difference between popup and regular drop-down menus is the separator that is used.
FYI
When you use menus from the menubar, they produce a JPopupMenu and similarly submenus are JPopupMenus. This in only an interesting factoid and doesn't seem to have any programming relevance, but it does the question of the difference between JSeparator