title: why is my code executing paintComponent(Graphics page) twice?
body: <p>This is getting on my nerves and it probably something silly on my part but I can't figure out why my paintComponent is being called twice, if you run my code it outputs REPEAT? REPEAT? twice, I don't want it to do that.. So why does it do it and how can I fix it?</p>
  
  <pre><code>import java.util.Random;
  import javax.swing.JFrame;
  import javax.swing.JPanel;
  import java.awt.*;
  
  public class Main extends JPanel {
  
  
      public Main()
      {      
       /*code here*/
      }
  
      public void paintComponent(Graphics page)
      {
       clear(page);
  
          /*code here*/
  
          System.out.println("REpEAT?"); 
  
      }
  
      protected void clear(Graphics page) {
          super.paintComponent(page);
        }
  
      public static void main (String[] args)
      {
          JFrame frame = new JFrame ("Circles");
          frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
          frame.setSize(300, 200);
          frame.getContentPane().add(new Main());
          frame.setVisible(true);
  
      }
  
  
  
  }
  </code></pre>