title: Multiple buttons and multiple listeners doing various operations Java Swing
body: <p>How can I have multiple buttons and multiple listeners doing various operations in java swing. Here is an example of what I have, I can redirect to the AddStudent class but the button to redirect to the AddAdult class wont redirect to the AddAdult class.</p>
  
  <pre><code>private class ButtonHandler implements ActionListener {
    // handle button event
    public void actionPerformed( ActionEvent Student ) {
      if ( Student.getSource() == button1 ){
        try {
          AddStudent newmember = new AddStudent();
          newmember.setVisible( true );
        } catch ( Exception e1 ) {
          e1.printStackTrace();
        }
    }
  }
  
  
  public void actionPerformed( ActionEvent Adult ) {
    if ( Adult.getSource() == button2 ){
      try {
        AddAdult newmember = new AddAdult();
        newmember.setVisible( true );
      } catch ( Exception e1 ) {
        e1.printStackTrace();
      }
    }
  }
  </code></pre>
  
  <p>Thanks for any help in advance.</p>