@Override
  public Dimension getPreferredSize(JComponent comp) {
    checkArrowIcon();
    JMenuItem menuItem = (JMenuItem)comp;
    Icon icon = getIcon();
    Icon secondaryIcon = getSecondaryIcon();
    Icon checkIcon = getCheckIcon();
    checkEmptyIcon(comp);
    String text = menuItem.getText();
    String keyStrokeText = getKeyStrokeText(menuItem);
    FontMetrics fontMetrics = comp.getFontMetrics(menuItem.getFont());
    FontMetrics keyStrokeMetrics = comp.getFontMetrics(acceleratorFont);
    initBounds();
    layoutMenuItem(fontMetrics, text, keyStrokeMetrics, keyStrokeText, icon, secondaryIcon, checkIcon, arrowIcon, menuItem.getVerticalAlignment(),
                   menuItem.getHorizontalAlignment(), menuItem.getVerticalTextPosition(), menuItem.getHorizontalTextPosition(),
                   ourViewRect, ourIconRect, ourSecondaryIconRect, ourTextRect, ourAcceleratorRect, ourCheckIconRect, ourArrowIconRect,
                   text != null ? defaultTextIconGap : 0, defaultTextIconGap);
    Rectangle rect = new Rectangle();
    rect.setBounds(ourTextRect);
    SwingUtilities.computeUnion(ourIconRect.x, ourIconRect.y, ourIconRect.width, ourIconRect.height, rect);
    if (!(keyStrokeText == null || keyStrokeText.isEmpty())){
      rect.width += ourAcceleratorRect.width;
      rect.width += 7 * defaultTextIconGap;
    }
    if (secondaryIcon != null) {
      rect.width += ourSecondaryIconRect.width + 2 * defaultTextIconGap;
    }
    if (useCheckAndArrow()){
      rect.width += myMaxGutterIconWidth;
      rect.width += defaultTextIconGap;
      rect.width += defaultTextIconGap;
      rect.width += ourArrowIconRect.width;
    }
    rect.width += 2 * defaultTextIconGap;
    Insets insets = menuItem.getInsets();
    if (insets != null){
      rect.width += insets.left + insets.right;
      rect.height += insets.top + insets.bottom;
    }
    if (rect.width % 2 == 0) {
      rect.width++;
    }
    if (rect.height % 2 == 0) {
      rect.height++;
    }

    return IdeaMenuUI.patchPreferredSize(comp, rect.getSize());
  }
@Override
  public Dimension getPreferredSize(JComponent comp)