@Override
  public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    Graphics2D g2 = (Graphics2D)g.create();

    try {
      Object avoidExtendingObject = ClientProperty.get(c, AVOID_EXTENDING_BORDER_GRAPHICS);
      g2.setRenderingHint(IdeBackgroundUtil.NO_BACKGROUND_HINT, avoidExtendingObject != null && avoidExtendingObject.equals(Boolean.TRUE));
      g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
                          MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);

      boolean isSmallComboButton = isSmallVariant(c);
      boolean isDefaultButton = isDefaultButton((JComponent)c);
      boolean isGotItButton = isGotItButton(c);
      int diam = HELP_BUTTON_DIAMETER.get();
      float lw = LW.getFloat();
      float bw = isSmallComboButton || isGotItButton ? 0 : BW.getFloat();
      float arc = isTag(c) ? height - bw * 2 - lw * 2: BUTTON_ARC.getFloat();

      Rectangle r = new Rectangle(x, y, width, height);
      boolean paintComboFocus = isSmallComboButton && c.isFocusable() && c.hasFocus();
      if (paintComboFocus) { // a11y support
        g2.setColor(JBUI.CurrentTheme.Focus.focusColor());

        Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD);
        border.append(new RoundRectangle2D.Float(r.x, r.y, r.width, r.height, arc + lw, arc + lw), false);
        border.append(new RoundRectangle2D.Float(r.x + lw * 2, r.y + lw * 2, r.width - lw * 4, r.height - lw * 4, arc, arc), false);
        g2.fill(border);
      }

      if (!isGotItButton) JBInsets.removeFrom(r, JBUI.insets(1));

      g2.translate(r.x, r.y);

      boolean newUiBorderPainted = false;
      if (!isSmallComboButton && !isGotItButton) {
        if (c.hasFocus()) {
          if (UIUtil.isHelpButton(c)) {
            paintFocusOval(g2, (r.width - diam) / 2.0f, (r.height - diam) / 2.0f, diam, diam);
          }
          else if (isTag(c)) {
            paintTag(g2, r.width, r.height, c.hasFocus(), computeOutlineFor(c));
          }
          else {
            newUiBorderPainted = paintNormalFocusBorder((Graphics2D) g, (JComponent)c, new Rectangle(x, y, width, height));
            if (!newUiBorderPainted) {
              Outline type = isDefaultButton ? Outline.defaultButton : Outline.focus;
              paintOutlineBorder(g2, r.width, r.height, arc, true, true, type);
            }
          }
        }
        else if (isTag(c)) {
          paintTag(g2, r.width, r.height, c.hasFocus(), computeOutlineFor(c));
        }
      }

      g2.setPaint(getBorderPaint(c));

      if (UIUtil.isHelpButton(c)) {
        g2.draw(new Ellipse2D.Float((r.width - diam) / 2.0f, (r.height - diam) / 2.0f, diam, diam));
      }
      else if (!paintComboFocus && !newUiBorderPainted) {
        Path2D border = new Path2D.Float(Path2D.WIND_EVEN_ODD);
        border.append(new RoundRectangle2D.Float(bw, bw, r.width - bw * 2, r.height - bw * 2, arc, arc), false);

        if (!isGotItButton) {
          arc = arc > lw ? arc - lw : 0.0f;
        }
        border.append(new RoundRectangle2D.Float(bw + lw, bw + lw, r.width - (bw + lw) * 2, r.height - (bw + lw) * 2, arc, arc), false);

        g2.fill(border);
      }
    }
    finally {
      g2.dispose();
    }
  }
@Override
  public void paintBorder(Component c, Graphics g, int x, int y, int width, int height)