Here you can find the source of addSeparatorIfNecessary(JPopupMenu popup)
public static void addSeparatorIfNecessary(JPopupMenu popup)
//package com.java2s; //License from project: Open Source License import javax.swing.JPopupMenu; import javax.swing.JSeparator; public class Main { public static void addSeparatorIfNecessary(JPopupMenu popup) /* */{//from ww w. j a v a2s .c om /* 3637 */int count = popup.getComponentCount(); /* 3638 */if ((count > 0) && (!(popup.getComponent(count - 1) instanceof JSeparator))) /* 3639 */popup.addSeparator(); /* */} }