// Fields to store a point in. // Called when the user clicks. last_x = x; last_y = y; // Remember the location of the click. return true;
Graphics g = getGraphics(); // Get a Graphics to draw with. g.drawLine(last_x, last_y, x, y); // Draw a line from last point to this. last_x = x; last_y = y; // And update the saved location. return true;