title: multiple JButton actionlistener from another class
body: <p>hi everyone i have a problem on how to create a separate class of actionlistener
  this is my code right now which works fine but doesn't fill my needs.</p>
  
  <pre><code>for (int x = 0; x &lt; buttons.length; x++) {
      buttons[x] = new JButton(name[x]);
      buttons[x].addActionListener(this);
  
  }
  public void actionPerformed(ActionEvent e) {
      if (e.getSource() == buttons[0]) {
          //command
      } else if (e.getSource() == buttons[1]) {
          //command
      }  
  
  }
  </code></pre>
  
  <p>So basically i want these buttons to have an action listener from another class.    </p>