title: Swing component listening to itself vs inner classes
body: <p>I just got some bad feedback on a uni project and need some impartial clarification;</p>
  
  <p>Can anyone explain when I should use (anonymous) inner listener classes vs components that listen to themselves? (a vs b)</p>
  
  <p>a)</p>
  
  <pre><code>public class myButton extends JButton {
  
      public myButton() {
  
          addActionListener(new ActionListener() {
  
              public void actionPerformed(ActionEvent e) {
                  // handling code...
  
              }
          });
      }
  }
  </code></pre>
  
  <p>b)</p>
  
  <pre><code>public class myButton extends JButton implements ActionListener {
  
      public myButton() {
  
          addActionListener(this);
      }
  
      public void actionPerformed(ActionEvent e) {
  
          // handle the event
      }
  }
  </code></pre>
  
  <p>Thanks guys,
  Mitch</p>