import java.awt.Graphics;
import java.awt.Color;
import java.awt.Event;

public class Zeichnen1 extends java.applet.Applet
{
   int x, y, lastX, lastY;
   boolean isDown;

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

   public boolean mouseDown ( Event e, int x, int y )
   {
      lastX = x;
      lastY = y;
      isDown = true;
      return true;
   }	
 
   public boolean mouseUp ( Event e, int x, int y )
   {
      isDown = false;
      return true;
   }	

   public boolean mouseDrag ( Event e, int x, int y )
   {
      if ( isDown )
      {
         this.x = x;
         this.y = y;
         repaint();
      }
      return true;
   }

   public void paint ( Graphics g )
   {
      g.drawLine ( lastX, lastY, x, y );
      lastX = x;
      lastY = y;
   }
  
}
