I'm trying to make a 10x10 "grid" of labels, with each label in each row named sequentially.
eg.
A1 A2 A3 A4.....
B1 B2 B3 B4.....
C1 C2 C3 C4....
Here is the code that I tried for creating the first row:
But this, as I discovered, does not insert the value of 'i' into the variable name. You guys have any suggestions on how to go about this?
eg.
A1 A2 A3 A4.....
B1 B2 B3 B4.....
C1 C2 C3 C4....
Here is the code that I tried for creating the first row:
Code:
for (int i=1;i<=10;i++)
{
JLabel Ai = new JLabel();
Ai.setOpaque(true);
Ai.setBackground(Color.blue);
Ai.setPreferredSize(new Dimension(GRID_WIDTH,GRID_HEIGHT));
Ai.setBorder(new LineBorder(Color.black, 1));
gameBoard.add(Ai);
}
But this, as I discovered, does not insert the value of 'i' into the variable name. You guys have any suggestions on how to go about this?