Here you can find the source of addSeparator(JMenu menu)
public static void addSeparator(JMenu menu)
//package com.java2s; import javax.swing.*; public class Main { public static void addSeparator(JMenu menu) { if (menu.getComponentCount() > 0) menu.add(new JSeparator()); }/*from ww w . j a va 2s . c o m*/ }