title: Calling paintComponent() with parameters using repaint()
body: <p>I am very new to graphics with Java, so just ask if any additional information is needed :)</p>
  
  <p>I am trying to paint shapes based on where the mouse clicks on the screen. Because of this, I need to pass the x and y coordinates of where I clicked to the <code>paintComponent()</code> method so that it will know where to paint the shape.</p>
  
  <pre><code>public void mouseClicked(MouseEvent e) {
      System.out.println("Adding Shape");
      repaint();
  }
  
  class CanvasDrawArea extends JPanel{
      //this should run when the program first starts
      @Override
      public void paintComponent(Graphics g){
          super.paintComponent(g);
          canvas.setBackground(CANVAS_COLOR);
      }
  
      //here is where the question is
      public void paintComponent(Graphics g, int x, int y){
          super.paintComponent(g);
          g.fillRect(x, y, RECTANGLE_WIDTH, RECTANGLE_HEIGHT);
      }
  }
  </code></pre>
  
  <p>basically I am trying to overload the paintComponent by having one that runs right when the program starts by calling the <code>repaint()</code> / <code>pack()</code> method, and one that will run when I give it the x and y coordinates. I am unsure, however, how I am supposed to go about passing the x and y parameters, as there is no way to pass them in the <code>repaint()</code> method.</p>