This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
jQuery in Action, 2nd edition
subject: multidimensional arraylist of JTextFields
Similar Threads
expandable multidimensional ArrayList or Multidimensional Arrays?
Multidimensional ArrayList
Multidimensional Arrays!
multidimensional array
multidimensional array