Wondering how one goes about testing which button was clicked in an actionperformed method. For example if I have 2 buttons named button1 and button2, and create an if statement what is the proper syntax, ive tried this but get errors. Where am i going wrong?
//declaring buttons
Panel buttonPanel = new Panel();
Button button1 = new Button("go");
Button button2 = new Button("stop");
//action performed method
public void actionPerformed(ActionEvent e)
{
if(button1)
{
//what button1 will do
}
else
{
//what button2 will do
}
}