Ereignis-Behandlung in Applets (II)

Id: event.tex,v 1.2 2004/12/09 06:28:24 waldmann Exp

public class Counter { ...
 void step () { ticks++; }
 Button inc = new Button ("inc");
 class Inc_Listen implements ActionListener {
  public void actionPerformed (ActionEvent a) {
    step(); update ();
  }
 }
 public void init () { ...
  add (inc);
  inc.addActionListener (new Inc_Listen ());
 }
}
Aufgaben: füge Knöpfe für decrement und reset hinzu.



Johannes Waldmann 2005-01-25