What I want to do that is to have two root nodes in a tree and each root node has subroots. So the tree structure will look like:
----Root 1
|-------subRoot1
|-------subRoot2
----Root 2
|-------subRoot3
I couldn't get it work. Anyone know how to do it?
----Root 1
|-------subRoot1
|-------subRoot2
----Root 2
|-------subRoot3
I couldn't get it work. Anyone know how to do it?
Code:
DefaultMutableTreeNode[] root = {new DefaultMutableTreeNode("Root1"),new DefaultMutableTreeNode("Root2")};
DefaultMutableTreeNode subRoot1 = new
DefaultMutableTreeNode("subRoot1");
DefaultMutableTreeNode subRoot2= new
DefaultMutableTreeNode("subRoot2");
root[0].add(subRoot1);
root[0].add(subRoot2);
DefaultMutableTreeNode subRoot3= new
DefaultMutableTreeNode("subRoot3");
root[1].add(subRoot3);
jTree = new JTree(root);