title: How to smooth out corners in rounded rectangle, Swing?
body: <p>I'm getting extremely pixilated corners when i try to make a rounded rectangle. Is there any way to smooth them out?</p>
  
  <p>Here's an image (Notice the corners):</p>
  
  <p><img src="https://i.stack.imgur.com/bQYQh.png" alt="enter image description here"></p>
  
  <p>Here is the code for the Button that I subclass and override the paint method (The one with the pixilated corner):</p>
  
  <pre><code>public class ControlButton extends JButton {
  
      public final static Color BUTTON_TOP_GRADIENT = new Color(176, 176, 176);
      public final static Color BUTTON_BOTTOM_GRADIENT = new Color(156, 156, 156);
  
      public ControlButton(String text) {
          setText(text);
      }
  
      public ControlButton() {
      }
  
      @Override
      protected void paintComponent(Graphics g){
          Graphics2D g2 = (Graphics2D)g.create();
          g2.setPaint(new GradientPaint(
                  new Point(0, 0), 
                  BUTTON_TOP_GRADIENT, 
                  new Point(0, getHeight()), 
                  BUTTON_BOTTOM_GRADIENT));
          g2.fillRoundRect(0, 0, getWidth(), getHeight(), 20, 20);
          g2.dispose();
      }
  }
  </code></pre>