Problem of Creating JTree with Hashtable ?
Posted on 2000-04-18
Currently I'm facing a problem with the node order of the JTree generated from the Hashtable. The order in which objects are added to a Hashtable exhibit an unpredictable node order. It seems that there has no correlation to the manner in which the objects are stored in the Hashtable.
eg. the order to put a object into the Hashtable.
Hashtable ht = new Hashtable();
ht.put("Page 1", page1Vector);
ht.put("Page 2", page2Vector);
JTree jt = new JTree(ht);
The node order of the JTree might be "Page 2" as a first node and "Page 1" as a second node which is not in the desired order.
Is there any way to solve the ordering problem or sorting the Hashtable ?
Hope to hear from you soon, thank you.