title: How to draw a filled oval where a mouse clicked on Jpanel
body: <p>I want to write a code to draw a filled oval where ever the mouse is clicked inside a panel. I used to develop some codes but unfortunately when I tried to do the next click the whole panel blanked and new point appeared. I want to keep the previous points and add some new ones by the next user’s click on the panel. How do I implement the paint component of <code>MyPanel</code>? Here is my code; it does not work properly, because it produces some small points instead of rectangle.</p>
  
  <pre><code>class MyPanel extends JPanel {
  Point pointClicked;
  
  public MyPanel() {
       this.addMouseListener(new MouseAdapter() {
          @Override
           public void mouseClicked(MouseEvent e) {
               pointClicked = e.getPoint();
           }
       });
  }
  @Override
  public void paintComponent(Graphics g) {
      super.paintComponent(g);
      g.fillRect(pointClicked.x, pointClicked.y, 1, 1);
  }
  }
  </code></pre>