Calling paintComponent() with parameters using repaint()
问题 I am very new to graphics with Java, so just ask if any additional information is needed :) 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 paintComponent() method so that it will know where to paint the shape. public void mouseClicked(MouseEvent e) { System.out.println("Adding Shape"); repaint(); } class CanvasDrawArea extends JPanel{ //this should run when the program first starts