@SuppressWarnings("SameParameterValue")
  private String layoutMenuItem(
    FontMetrics fontMetrics,
    @NlsContexts.Command String text,
    FontMetrics keyStrokeMetrics,
    @NlsContexts.Label String keyStrokeText,
    Icon icon,
    Icon secondaryIcon,
    Icon checkIcon,
    Icon arrowIcon,
    int verticalAlignment,
    int horizontalAlignment,
    int verticalTextPosition,
    int horizontalTextPosition,
    Rectangle viewRect,
    Rectangle iconRect,
    Rectangle secondaryIconRect,
    Rectangle textRect,
    Rectangle acceleratorRect,
    Rectangle checkIconRect,
    Rectangle arrowIconRect,
    int textIconGap,
    int menuItemGap
  ) {
    SwingUtilities.layoutCompoundLabel(menuItem, fontMetrics, text, icon, verticalAlignment, horizontalAlignment, verticalTextPosition,
                                       horizontalTextPosition, viewRect, iconRect, textRect, textIconGap);
    if (keyStrokeText == null || keyStrokeText.isEmpty()){
      acceleratorRect.width = acceleratorRect.height = 0;
    }
    else{
      acceleratorRect.width = SwingUtilities.computeStringWidth(keyStrokeMetrics, keyStrokeText);
      acceleratorRect.height = keyStrokeMetrics.getHeight();
    }

    /* Initialize the checkIcon bounds rectangle's width & height.
     */
    if (useCheckAndArrow()){
      if (checkIcon != null){
        checkIconRect.width = checkIcon.getIconWidth();
        checkIconRect.height = checkIcon.getIconHeight();
      }else{
        checkIconRect.width = checkIconRect.height = 0;
      }

      /* Initialize the arrowIcon bounds rectangle width & height.
       */
      if (arrowIcon != null){
        arrowIconRect.width = arrowIcon.getIconWidth();
        arrowIconRect.height = arrowIcon.getIconHeight();
      }else{
        arrowIconRect.width = arrowIconRect.height = 0;
      }
      textRect.x += myMaxGutterIconWidth;
      iconRect.x += myMaxGutterIconWidth;
    }
    textRect.x += menuItemGap;
    iconRect.x += menuItemGap;
    Rectangle labelRect = iconRect.union(textRect);

    // Position the secondary icon
    if (secondaryIcon != null) {
      secondaryIconRect.width = secondaryIcon.getIconWidth();
      secondaryIconRect.height = secondaryIcon.getIconHeight();
      secondaryIconRect.x = labelRect.x + labelRect.width + menuItemGap;
      secondaryIconRect.y = (labelRect.y + labelRect.height / 2) - secondaryIcon.getIconHeight() / 2;
    }

    // Position the Accelerator (shortcut) text rect
    acceleratorRect.x = viewRect.x + viewRect.width - arrowIconRect.width - (arrowIconRect.width > 0 ? menuItemGap : 0) - acceleratorRect.width;
    acceleratorRect.y = (viewRect.y + viewRect.height / 2) - acceleratorRect.height / 2;

    // Position the Check and Arrow Icons
    if (useCheckAndArrow()){
      arrowIconRect.x = viewRect.x + viewRect.width - arrowIconRect.width;
      arrowIconRect.y = (labelRect.y + labelRect.height / 2) - arrowIconRect.height / 2;
      if (checkIcon != null){
        checkIconRect.y = (labelRect.y + labelRect.height / 2) - checkIconRect.height / 2;
        checkIconRect.x += (viewRect.x + myMaxGutterIconWidth / 2) - checkIcon.getIconWidth() / 2;
      }
      else{
        checkIconRect.x = checkIconRect.y = 0;
      }
    }
    return text;
  }
@SuppressWarnings("SameParameterValue")
  private String layoutMenuItem(
    FontMetrics fontMetrics,
    @NlsContexts.Command String text,
    FontMetrics keyStrokeMetrics,
    @NlsContexts.Label String keyStrokeText,
    Icon icon,
    Icon secondaryIcon,
    Icon checkIcon,
    Icon arrowIcon,
    int verticalAlignment,
    int horizontalAlignment,
    int verticalTextPosition,
    int horizontalTextPosition,
    Rectangle viewRect,
    Rectangle iconRect,
    Rectangle secondaryIconRect,
    Rectangle textRect,
    Rectangle acceleratorRect,
    Rectangle checkIconRect,
    Rectangle arrowIconRect,
    int textIconGap,
    int menuItemGap
  )