Freihand zeichnen
Und das ist der ganze Quelltext (auch zum
download):
/*
*
* Copyright (c) 1996 - 1998
* Frank Buss (fb@frank-buss.de), Stephan Schloepke (stephan@nordrhein.net)
*
* This applet was published in the book:
*
* "Programmier Training Java, In 15 Stunden topfit"
* ISBN 3-8158-1303-4
* Authors: Frank Buss, Stephan Schloepke
* Data Becker Verlage (http://www.databecker.de)
*
* You can get this applet and more at http://www.frank-buss.de
*
*/
//
// Freihand zeichnen
//
import java.applet.*;
import java.awt.*;
public class Freihand extends Applet {
int altX;
int altY;
public boolean mouseDrag(Event evt, int x, int y) {
getGraphics().drawLine(altX, altY, x, y);
altX=x;
altY=y;
return true;
}
public boolean mouseDown(Event evt, int x, int y) {
altX=x;
altY=y;
return true;
}
}
11. November 1999, Frank Buß