import java.applet.Applet;
import java.awt.*;

// This appears in Core Web Programming from
// Prentice Hall Publishers, and may be freely used
// or adapted. 1997 Marty Hall, hall@apl.jhu.edu.

/** An applet that lets you perform freehand drawing. */

public class SimpleWhiteboard extends Applet {
  protected int lastX=0, lastY=0;

  public void init() {
    setBackground(Color.white);
  }

  public boolean mouseEnter(Event e, int x, int y) {
    return(record(x, y));
  }

  public boolean mouseDown(Event e, int x, int y) {
    return(record(x, y));
  }

  public boolean mouseDrag(Event e, int x, int y) {
    getGraphics().drawLine(lastX, lastY, x, y);
    return(record(x, y));
  }

  protected boolean record(int x, int y) {
    lastX = x;
    lastY = y;
    return(true);
  }
}
