title: Drawing a simple circle with Java swing does not work
body: <p>I think I am missing something really obvious but somehow this code does give me an empty window but it does not paint the red oval. What am I missing?</p>
  
  <pre><code>public class Test extends JPanel {
  
      @Override
      public void paintComponent(Graphics g) {
          super.paintComponents(g);
          g = this.getGraphics();
          Graphics2D g2 = (Graphics2D) g;
  
          // Anti-aliasing
          g2.setColor(new Color(255, 0, 0));
          g2.fillOval(0, 0, 20, 20);
      }
  
      public static void main(String[] args) {
          JFrame frame = new JFrame("Ball");
          Test panel = new Test();
  
          frame.getContentPane().add(panel);
          frame.setPreferredSize(new Dimension(250, 200));
          frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  
          frame.pack();
          frame.setVisible(true);
      }
  
  }
  </code></pre>