Draw something where the mouse clicks
Can't just draw...
Need to save mouse coords somewhere, then repaint()
Note previous drawing will be erased automatically
Keep all the items you have drawn
Optional: Use a cooler data structure
import java.util.*;
...
ArrayList<Point> points = new ArrayList<Point>();
...
points.add (event.getPoint());
repaint ();
...
for (Point p : points) {
g.draw (something at p.x, p.y)
}
Optional: Draw a path that follows mouse dragging
requires MouseMotionListener
Usually also your own state variable to remember if mouse is up or down
Or could use mouseDragged vs mouseMoved