Also possible:
final Timer timer = new Timer(10, null);
timer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
(as in the question, except that you can refer to timer here)
}
});
Or, use the event object to get the source (and cast it, boo):
final Timer timer = new Timer(10, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
((Timer)evt.getSource()).stop();
}
});
Or, keep the timer in an instance variable and you can reference it from your handler or have the handler call a method on your class which could stop/start it.