I have encountered a tricky problem for me in a project where i wan't to populate a JTree component object
with nodes which are constructed from a multidimensional array of tree data objects. Theese nodes are
inserted into my treemodel with the insertNodeInto(DefaultMutableTreeNode node, DefaultMutableTreeNode parent,
int index) method in the DefaultTreeModel class.
Below i have posted the following example of my TreeData class that i want to use in my tree nodes as a user object
The TreeData class in the above piece of code controls the layout in a JPanel object in my project's main class.
Anyway its not important for this post what this object does. As I said earlier I want to populate a JTree from TreeData objects
that reside within a multidiemensional array. The TreeData object that takes only one String object as a parameter in it's constructor
is user objects attached to the parent nodes in my JTree.
Below i have a piece of code that demonstrated how i wish to accomplish this attempt i could use another approach i am thinking of
doing this using xml parsing instead but for now i need some hint on how to populate the jtree object correctly so that the nodes will be
inserted into model in the correct order so far my node insertion attempts have only resulted in reversed order i am not good at
using the collection classes in java but i know the solution to this problem is there somewhere ...
Below theese lines are an example of what i have tried so far to populate my JTree object from a multi diemensional.
The code below only results in the fact that the nodes in my JTree appears in a reversed order.
How can i use the Set<Object> class or the ListIterator<Object> class
to iterate through my arrays of TreeData and insert them into a treemodel in the correct order and in a way similar to the one in the code example above this line?
I have only used collection classes with a single array of objects as a generic parameter. I hope i have been clear enough in the description of my problem in
question. I would really appreciate any kind of hint or help here and thanks a lot for your visit here.