Eileen Li Eileen Li - 5 months ago 9
Java Question

Getting Index of ArrayList of Array

I made an ArrayList of arrays of JTextField.
Now I want to get the value of the first position of the array that was previously stored in the ArrayList.

ArrayList <JTextField []> text_field;
text_field = new ArrayList <JTextField []> ();


I have tried doing this:

text_field.get (row)[column];


But this didn't work. How should I change it?

And how can I add the JTextField onto the panel?

for (int i = 0; i < text_field.size (); i++) {
for (int j = 0; j < 8; j++) {

}
}

Answer

Try this:

((JTextField[]) text_field.get(row))[column];