Hello and excuse me if the title is not very specific.
I have in a JAVA application a total of 197 JButton with names btn1, btn2, btn3, .... btn197 which corresponds to the parking spaces.
In the database that I own has the columns squares, which contains the squares by numbers (1, 2, 3, ... 197) and another column called state which will possess a 0 or 1.
When the status is 1 the button corresponding to the square number (btn1 = 1) should turn green.
The issue is that they are so many buttons that I do not want to make 197 sentences if
if(rs.getString(1).equals("1"))
{
btn1.setColor();
}
The question is this:
Can I call the variable of type JButton similar to (btn + "1").setColor()
or (btn + rs.getString(1).setColor())
in Java? Is there any way?
again apologize if the question and / or title was not well understood.
greetings