I'm making a Sudoku game. Now, i've got the logic working, where it tests to see if the numbers right. But here's my problem, the program consists of an ArrayList of 81 JTextFields, few of which are already set and unable to be edited (like the numbers given to you in a Sudoku puzzle). So my problem is that, i need to make an integer array of the actual numbers. So basically what's happening is that, the ArrayList is empty and I'm getting a NullPointerException.

Here is what i've been trying to do in order to convert. (Assume that i've done everything necessary to place the textfields in their place, and i've set some of the text of the textfields for the given numbers. Keep in mind, all of the following code is placed in the actionPerformed method for an inner class which implements ActionListener , and is used for when a JMenuItem is clicked).

ArrayList<JTextField> numbers = new ArrayList<JTextField>();
int[] actualNumbers = new int[81];
for(int x = 0; x < actualNumbers.length; x++)
actualNumbers[x] = Integer.parseInt(numbers.get(x).getText());
now, this compiles with no problem, but I get a NullPointerException after i fill in the textFields with random numbers when i click the JMenuItem. So its a problem with it reading the numbers from the textfields. which is where i need help.