e809. 在菜单中使菜单项分开

A separator typically appears as a horizontal line. It is used to group related sets of menu items in a menu.

    // Create a menu
    JMenu menu = new JMenu("Menu Label");
    
    // Add a menu item
    JMenuItem item1 = new JMenuItem("Item Label");
    menu.add(item1);
    
    // Add separator
    menu.add(new JSeparator());
    
    // Add another menu item
    JMenuItem item2 = new JMenuItem("Item Label");
    menu.add(item2);

 

Related Examples
posted @ 2018-09-06 08:53  borter  阅读(152)  评论(0编辑  收藏  举报