Code
JButton [] [] grid = new JButton [rows] [columns]; //creates 2D array of buttons
JPanel gamePanel = new JPanel(new GridLayout(rows, columns));
//GridLayout mineGrid = new GridLayout(rows, columns)
//creates the grid of buttons
for (int i = 0; i < rows - 1; i++)
{
for (int j = 0; j < columns - 1; j++)
{
grid [rows] [columns] = new JButton();
grid [rows] [columns].addMouseListener(this);
gamePanel.add(grid [rows] [columns]);
}
}
newFrame.add(gamePanel);
newFrame.pack();
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 16
line 16 being the one I singled out.
Also I'm trying to put the buttons in with GridLayout, but as you can see it's commented out because I'm not too sure about how to use it.
This post was edited by MachoMonkey89 on Jun 12 2012 02:03pm