The first is adding the ActionListener by creating an anonymous inner class and is the 'better' practice. The second is a common way to demonstrate ActionListeners in a single program element or class, but if the design is used on more complex programs, the programmer will eventually discover the program is a tangled mess of code that is difficult to untangle and maintain. It is advised to separate the business (model), interface (view), and controller logic as much as possible. A common design pattern (or architecture) to accomplish this is known as the Model View Controller, or MVC, pattern.