Der Java-Quellcode für das Zeichnen-Applet |
|
Die Datei: Zeichnen.java |
| import java.awt.*; import java.applet.*; public class Zeichnen extends Applet { private int x_pos=0; private int y_pos=0; public boolean mouseDown(Event e, int x, int y){ x_pos=x; y_pos=y; return true; } public boolean mouseDrag(Event e, int x, int y){ Graphics g=getGraphics(); g.drawLine(x_pos,y_pos,x,y); x_pos=x; y_pos=y; return true; } } |
|
Die Datei: Tafel.java |
| import java.awt.*; import java.applet.*; public class Tafel extends Zeichnen { private Button loeschKnopf; public void init(){ loeschKnopf = new Button("Loesche"); this.add(loeschKnopf); } public boolean action(Event e,Object arg){ if (e.target==loeschKnopf){ this.play(getDocumentBase(),"sound.au"); this.repaint();} return true; } } |