Hey im new to java in grade 10 and I came through a small problem. I'm creating the game 4 pics on word and I can't seem to put a different image in each square of my grid.
Here is the grid
The decleration:
int row = 4;
int col = 4;
JButton a[] = new JButton [row * col];
And here's the array:
card4 = new Panel ();
Panel g = new Panel (new GridLayout (row, col));
for (int i = 0 ; i < a.length ; i++)
{
a[i] = new JButton ("Hi");
a[i].setPreferredSize (new Dimension (50,50));
g.add (a[i]);
}
How would I call out each individual button on the grid and assign a different image to it?