I have a hundred buttons called
JButton btnHelp1, btnHelp2, … btnHelp100;
I want to go from string to a jbutton name for another method to set the foreground like so
for(x = 1; x < 101; x++){
String buttonName = "btnHelp" + x;
// convert by doing something like...
JButton a = buttonName;
a.setForeground(Color.yellow);
}
What you are describing isn’t possible. However, you can add all of your buttons in a
List, and go through every elements (buttons) of your list and change its background.