Suppose that I have a lot of variables defined in my code with names such as this
public javax.swing.JPanel BenderPanel1;
public javax.swing.JPanel BenderPanel2;
public javax.swing.JPanel BenderPanel3;
etc...
So their general type is like this: BenderPanel"NUMBER"
.
I want to access some of them and set their visibility with .setVisible(false);
but the number of those panels which I want to access is user-defined on run time.
Is there any possible way through a library to append a number to the end of each variable in order to access it in a for
loop, like this:
for (int i=1; i<=UserInput; i++)
{
BenderPanel"i".setVisible(false); // Watch this "i" right there.
}
WITHOUT the need to add them on ArrayList
first and do it with the obvious way?