Creating a Popup Menu with Nested Menus : Popup menu « Swing JFC « Java






Creating a Popup Menu with Nested Menus

 

import javax.swing.JMenu;
import javax.swing.JPopupMenu;

public class Main {
  public static void main(String[] argv) throws Exception {
    final JPopupMenu popupMenu = new JPopupMenu();

    JMenu submenu = new JMenu("SubMenu1");
    submenu.add("asdf");
    submenu.add("asdf");

    // Add submenu to popup menu
    popupMenu.add(submenu);
  }
}

   
  








Related examples in the same category

1.Creating a Popup Menu
2.A popup menu is sometimes called a context menu
3.Force the popup menu of a JMenu to be heavyweight
4.JPopupMenu with mouse event
5.set Component Popup Menu
6.Forcing a Popup Menu to Be a Heavyweight Component
7.Configure all popup menus to be heavyweight
8.setInheritsPopupMenu