JButton b = new JButton ("foo");
b.addActionListener (new ActionListener () {
void actionPerformed (ActionEvent ae) {
System.out.println ("click on foo");
} }
interface ActionListener
implementiert.
Das Befehlsmuster realisiert „Unterprogramm als Datum``. (Viele andere Muster tun das ebenso.)