I need to create a variable length, multidimensional array of JTextFields and labels. Is there a way to create a multidimensional ArrayList of this type?
posted 12 years ago
Since all Container objects in Java hold Object references, these Objects can be just about anything. To create a two dimensional ArrayList, you would simply create an ArrayList that contains several ArrayList objects which in turn contain references to JTextField objects. Also note that since the ArrayList only refers to its contents as Objects, they are inherently heterogeneous (i.e. they can hold several objects of different types). Contrast this to the homogeneous nature of arrays. I don't have time to post example code at the moment since I have to leave for class soon. I hope my comments here help spark some ideas for you. If you still run into problems, please post more questions along with any code you've come up with so far and a description of the problems you encounter (including compiler-errors and output). Good luck and keep coding! Layne