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.
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();
}
}
}
Thanks for any help in advance.