I want to implement a general method of handling clicks for a group of buttons using a switch. I can't get this idea down. With the help of if-else-if
public void onClickTab1Buttons(ActionEvent event){ if (event.getSource() == bt1) { lbl.setText("bt1"); } else if (event.getSource() == bt2) { lbl.setText("bt2"); } else if (event.getSource() == bt3) { lbl.setText("bt3"); } } I want something like this:
public void onClickTab1Buttons(ActionEvent event){ switch (event.getSource()){ case bt1: lbl.setText("bt1"); break; case bt2: lbl.setText("bt2"); break; case bt3: lbl.setText("bt3"); break; } }