JTree node not displayed
Hi,
I am trying to create a JTree node and for some reason, the subnodes of my main Trilili node are not displayed when I use the following code:
// Initializing top node
DefaultMutableTreeNode Trilili = new DefaultMutableTreeNode("Trilili",true);
TreeModel OurStuff = new DefaultTreeModel(Trilili,true);
TheTree.setModel(OurStuff);
// Initializing children node
DefaultMutableTreeNode Tralala = new DefaultMutableTreeNode("Tralala",true);
Trilili.add(Tralala);
DefaultMutableTreeNode Trololo = new DefaultMutableTreeNode("Trololo",true);
Trilili.add(Trololo);
DefaultMutableTreeNode SubNode = new DefaultMutableTreeNode("SubNode",true);
Tralala.add(SubNode);
Yet, if I move the
TreeModel OurStuff = new DefaultTreeModel(Trilili,true);
TheTree.setModel(OurStuff);
lines at the end of my code, the nodes are being displayed at all (I don't mean unfolded). Does it mean I have to recreate a TreeModel each time I modify the structure of my JTree?
Please don't send me to How to use tree Tutorial, I have already read it and I could not find the answer to my question. Thanks.

