@Override
  public void paintComponent(Graphics g) {
    Icon icon = getIcon();
    Icon arrowIcon = shallPaintDownArrow() ? getEnableOrDisable(getDownArrowIcon()) : null;

    UISettings.setupAntialiasing(g);

    FontMetrics fm = getFontMetrics(getFont());
    Rectangle viewRect = getButtonRect();
    JBInsets.removeFrom(viewRect, getInsets());
    JBInsets.removeFrom(viewRect, getMargins());

    Rectangle iconRect = new Rectangle();
    Rectangle textRect = new Rectangle();
    String text = SwingUtilities.layoutCompoundLabel(this, fm, getText(), icon,
                                                     SwingConstants.CENTER, horizontalTextAlignment(),
                                                     SwingConstants.CENTER, horizontalTextPosition(),
                                                     viewRect, iconRect, textRect, iconTextSpace());
    if (arrowIcon != null) {
      int alignment = horizontalTextAlignment();
      int dx = alignment == SwingConstants.CENTER ? arrowIcon.getIconWidth() / 2 - 2:
               alignment == SwingConstants.RIGHT ? arrowIcon.getIconWidth() :
               0;
      iconRect.x -= dx;
      textRect.x -= dx;
    }
    ActionButtonLook look = getButtonLook();
    look.paintBackground(g, this);
    look.paintIcon(g, this, icon, iconRect.x, iconRect.y);
    look.paintBorder(g, this);

    g.setColor(isEnabled() ? getForeground() : getInactiveTextColor());
    UIUtilities.drawStringUnderlineCharAt(this, g, text, getMnemonicCharIndex(text),
                                          textRect.x, textRect.y + fm.getAscent());
    if (arrowIcon != null) {
      int x = Math.max(iconRect.x + iconRect.width, textRect.x + textRect.width) + JBUI.scale(TEXT_ARROW_SPACE);
      int y = textRect.y + (textRect.height - arrowIcon.getIconHeight()) / 2 + 1;
      getButtonLook().paintIcon(g, this, arrowIcon, x, y);
    }
  }
@Override
  public void paintComponent(Graphics g)