next up previous
Nächste Seite: Manager (II) Aufwärts: Layout-Manager (19. 12.) Vorherige Seite: Implizite Positionierung durch Manager

ActionListener (Wiederholung)

$ $Id: action.tex,v 1.1 2003/12/18 23:41:09 joe Exp $ $

Label top = new Label ("Top");
int status = 0;
void update () { top.setText 
     (Integer.toString (status));
}
class Step implements ActionListener {
  int myself;
  public Step (int k) { myself = k; }
  public void actionPerformed (ActionEvent a) 
    { status += myself; update (); } 
}

Button b = new Button ( .. );
b.addActionListener (new Step (11));



Johannes Waldmann 2004-01-30