File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes multidimensional arraylist of JTextFields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "multidimensional arraylist of JTextFields" Watch "multidimensional arraylist of JTextFields" New topic

multidimensional arraylist of JTextFields

Tyler Jordan
Ranch Hand

Joined: Nov 17, 2003
Posts: 70
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?
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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!

Java API Documentation
The Java Tutorial
I agree. Here's the link:
subject: multidimensional arraylist of JTextFields
It's not a secret anymore!