title: How to keep paintComponent() from running at the beginning?
body: <p>I am trying to make something similar to Paint and I've run into a bit of a snag. Basically you paint in a JPanel that calls paintComponent(). However, when the program is run, an unwanted dot appears in the upper left corner. I think it is because paintComponent() is called at the start of the program. Is there any way to disable this? The code is listed below (I removed the imports) and thanks for reading.
  Here is the paintBoard class:</p>
  
  <pre><code>public class PaintBoard extends JPanel implements MouseListener
  {
  Image img;
  //PaintBoard panel;
  int circleX = 25;
  int circleY = 25;
  int x;
  int y;
  
  public PaintBoard()
  {
      this.addMouseListener(this);
  }
  public void paintComponent(Graphics g)
  {       
      g.setColor(Color.RED);
  
      g.fillOval(x, y, circleX, circleY);
  }
  public void mouseClicked(MouseEvent arg0) 
  {   
  }
  public void mouseEntered(MouseEvent arg0) 
  {       
  }
  public void mouseExited(MouseEvent arg0) 
  {   
  }
  public void mousePressed(MouseEvent arg0) 
  {
      x = arg0.getX();
      y = arg0.getY();;
  
  
      repaint();
  }
  public void mouseReleased(MouseEvent arg0) 
  {   
  }
  
  }
  </code></pre>
  
  <p>And here is the main class:</p>
  
  <pre><code>public class Main 
  {
  JFrame mainFrame = new JFrame("Painting test");
  PaintBoard board = new PaintBoard();
  
  
  
  public Main() throws IOException
  {   
      mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      mainFrame.setSize(1750, 1000);
      mainFrame.setLayout(new GridLayout(2, 2));
      mainFrame.add(board);
      //mainFrame.pack();
      mainFrame.setVisible(true);
  }
  
  public static void main(String[] args) throws IOException 
  {
      new Main();
  }
  
  }
  </code></pre>