code: public static void removeConsecutiveSeparators(JPopupMenu popupMenu) {
          for (int i = 1; i < popupMenu.getComponentCount(); i++) {
              if (isPopupMenuSeparator(popupMenu.getComponent(i))) {
                  if (isPopupMenuSeparator(popupMenu.getComponent(i - 1))) {
                      popupMenu.remove(i);
                      i--;
                  }
              }
          }
      }
docs: Removes all consecutive separators from the given menu.
  <p>
  For example, calling the method on the given menu:
  <pre>
  Menu Entry
  Separator
  Menu Entry
  Separator
  Separator
  Menu Entry
  </pre>
  would result in:
  <pre>
  Menu Entry
  Separator
  Menu Entry
  Separator
  Menu Entry
  </pre>
  
  @param popupMenu the pop up menu whose consecutive separators will be removed
  @see javax.swing.JPopupMenu.Separator