Mega Code Archive

 
Categories / Java / Swing JFC
 

Separating Menu Items in a Menu

import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JSeparator; public class Main {   public static void main(String[] argv) throws Exception {     JMenu menu = new JMenu("Menu Label");     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);   } }