Here you can find the source of addSeparatorIfNecessary(JPopupMenu popup)
Parameter | Description |
---|---|
popup | the popup menu. |
public static void addSeparatorIfNecessary(JPopupMenu popup)
//package com.java2s; import javax.swing.*; public class Main { /**//from ww w . j av a2 s .co m * Adds a separator to the popup menu if there are menu items on it already. * * @param popup the popup menu. */ public static void addSeparatorIfNecessary(JPopupMenu popup) { int count = popup.getComponentCount(); if (count > 0 && !(popup.getComponent(count - 1) instanceof JSeparator)) { popup.addSeparator(); } } }