Creating a Contextual Menu

See Also

  1. In the Palette window, click a contextual menu component:
    icon for JPopupMenu - JPopupMenu in the Swing components category
    icon for PopupMenu - PopupMenu in the AWT components category
  2. Click anywhere in the form to add the menu. The new menu appears under the Other Components list in the Inspector window. You can use the same menu-editing features that you use with a menu bar.
  3. Write code similar to this where you want to show the contextual menu:
    popupMenu1.show (component, 100, 100);
    

    See the API documentation that comes with the Java 2 SDK for more details.

See Also
Creating a Menu Bar
Changing the Current Menu Bar
Adding a Menu to a Menu Bar
Adding a Menu Item
Adding an Event Handler to a Menu Item

Legal Notices