I have a button which I want to do something different the second time it is clicked. For this purpose I have the clicked button handler check for the button's name, and I change this name the first time it is pressed.
The button name does not change though, do I need to repack or update the buttonpanel it belongs to somehow?
@Override
public void actionPerformed(ActionEvent e) {
switch(((JButton) e.getSource()).getName()) {
case "TR":
((JButton) e.getSource()).setName("Done TR");
awaitPoints("TR");
break;
case "Done TR":
CP.ComputeTransfo();
((JButton) e.getSource()).setName("TR Complete");
((JButton) e.getSource()).setEnabled(false);
break;
default:
System.out.println("ERROR:TFM01");
System.exit(0);
break;
}
}