What\'s the best way for implementing the java.awt.event.ActionListener
interface?
Have your class implement ActionListener and add this as an ActionLis
It depends. If you want to reuse the ActionListener
across multiple components, option one is better. If the ActionListener
will only ever be associated with the one button, option two is fine.
Generally, you would create a separate class (or inner class), if you anticipate some growth in the project. There's no need for Foo
to implement ActionListener
.