code: public static void removeTopSeparators(JPopupMenu popupMenu) {
          while (popupMenu.getComponentCount() > 0 && isPopupMenuSeparator(popupMenu.getComponent(0))) {
              popupMenu.remove(0);
          }
      }
docs: Removes all top separators from the given pop up menu.
  <p>
  For example, calling the method on the given menu:
  <pre>
  Separator
  Separator
  Menu Entry
  Separator
  Menu Entry
  Separator
  Menu Entry
  </pre>
  would result in:
  <pre>
  Menu Entry
  Separator
  Menu Entry
  Separator
  Menu Entry
  </pre>
  
  @param popupMenu the pop up menu whose top separators will be removed
  @see javax.swing.JPopupMenu.Separator