Hello, I have to make a sudoku-like GUI puzzle for a program. I was originally going to do this by using a GridLayout but decided it was easier toedit the JTextFields by making a 2D array of JTextFields. However, I am getting an ArrayIndexOutOfBoundsException and I have no idea why. Can someone please help?
This is the section of code that is getting the error:
private Component getPuzzle() {
JPanel puzzlePanel = new JPanel();
int col = 16;
int row = 16;
JTextField sudoku[][] = new JTextField[col][row];
//puzzlePanel.setLayout(new GridLayout(col,row,1,1));
puzzlePanel.add(sudoku[col][row]);
for (int i =0; i < row*col; i++) {
puzzlePanel.add(new JTextField());
}
return puzzlePanel;
}