Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

multidimensional arraylist of JTextFields

 
Tyler Jordan
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic