I'm trying to define a swing button label by using a string and then converting the string to a button name and then using the name to set the label.
Somehow it doesn't work, and I've tried to use getClass(); and Class.forName();
Here is my custom class where I try to change a button label by putting in the button name as a string;
public void zet(String scl){
Class c = scl.getClass();
//Class c = Class.forName(scl);
if (beurt) {
c.setLabel("X");
beurt = false;
} // end of if
else{
c.setLabel("O");
beurt = true;
}}
Can somebody please help me with this? Many thanks in advance.