Example:  Simple Whiteboard

1.  SimpleWhiteboard.java

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

/** A 1.02 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) {
  	Graphics g = getGraphics();
    g.drawLine(lastX, lastY, x, y);
    return(record(x, y));
  }

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

    Source

2.  Simple Whiteboard Output

The Simple Whiteboard Applet

Sorry, you are using a Java-challenged browser.

    Source

© 1996-98 Marty Hall, 1999 Lawrence M. Brown