I got a button on a JFrame called button1. And of course I know I can use a reference using the name....
this.button1.setBackground(Color.green);
But lets suppose I got 80 buttons on the screen and I got the name of the button in a string.
String name="button1";
And I need to do the same task of assigning an icon or colors or something to that button called button1.
In some place I saw a class named Object and (as far as I understood) I can transfer the name from the string to an object that will act like an alias of the button (at least that is what I believe).
Object button = new Object();
button = name ;
this.button.setBackground(Color.green);
But its not working at all. :(
As you can see (clearly) I'm new in Java so maybe I'm doing something stupid or maybe this is not the way of doing it.
I can compose on a string the name of every button on the screen, but I need to know how to reference that button from the string.
I will appreciate any help.