title: Should your class implement ActionListener or use an object of an anonymous ActionListener class
body: <p>What's the best way for implementing the <code>java.awt.event.ActionListener</code> interface?</p>
  
  <p>Have your class implement ActionListener and add this as an ActionListener:</p>
  
  <pre><code>class Foo implements ActionListener{
  
      public Foo() {
          JButton button = new JButton();
          button.addActionListener(this);
      }
  
      public void actionPerformed(ActionEvent e) {
  
      }
  }
  </code></pre>
  
  <p>Or add an object of an anonymous ActionListener class:</p>
  
  <pre><code>class Foo{
  
      public Foo() {
          JButton button = new JButton();
          button.addActionListener(new ActionListener() {     
              public void actionPerformed(ActionEvent e) {
  
              }
          });
      }
  }
  </code></pre>