class Counter { ... class AL implements ActionListener { void ActionPerformed (ActionEvent e) { ... } } Button b = new Button ("but"); public void init () { ... b.addActionListener (new AL ()); } }