code: public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
  
          final Graphics2D g2 = (Graphics2D) g.create();
          g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  
          // In real code optimize by preserving the rect between calls
          if (stroke != null) {
              final int i = (int) strokeWidth / 2;
              final RoundRectangle2D.Float rect = //
              new RoundRectangle2D.Float(i, i, width - strokeWidth, height - strokeWidth, arc, arc);
              g2.translate(x, y);
              g2.setColor(c.getBackground());
              g2.fill(rect);
  
              g2.setColor(strokeColor);
              g2.setStroke(stroke);
              g2.draw(rect);
          } else {
              final RoundRectangle2D.Float rect = new RoundRectangle2D.Float(0, 0, width, height, arc, arc);
              g2.translate(x, y);
              g2.setColor(c.getBackground());
              g2.fill(rect);
          }
      }
docs: {@inheritDoc}