Creating a Contextual Menu

  1. Click the contextual menu icon under the AWT or Swing tab in the Component Palette. (Tool tips for these menu icons are PopupMenu and JPopupMenu, respectively.)
  2. Click anywhere in the form to add the menu. The new menu appears under the Other Components list in the Component Inspector. 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