- import objectdraw.*;
- import java.awt.*;
- // This program allows its user to draw simple lines on the screen
- // using the mouse as if it were a pencil.
- public class Scribble extends WindowController {
- Location previousPosition; // Last known position of mouse
- // When the mouse button is depressed, note its location
- public void onMousePress( Location pressPoint) {
- previousPosition = pressPoint;
- }
- // Connect current and previous mouse positions with a line
- public void onMouseDrag( Location currentPosition) {
- previousPosition = currentPosition;
- }
- }
Raw Paste