>> Sounds like you need to reload the tree after rebuilding it:
>>
>> ((DefaultTreeModel) jTree1.getModel()).reload();
>
> Thanks for that, but it didn't seem to work unfortunatly. Still
> display sthe default tree.
Where do you do the init of the JTree? I had the same problem.
Basically, I think the correct solution is to initialize the JTree
before pack() and setVisible() is called on the higher level container
(JFrame, JWindow, etc.)
On the left, in the Inspector window, select the JTree component then
right click and open the properties window. Select the CODE tab. You
can add code here. I added two lines in the pre-creation code, and one
line in the custom creation code line. I use the minimum number of
lines because it's a pretty small box you have to enter it in, and I can
call a static method with one line, and put everything important in
there where it's easy to modify. (As opposed to the little box in the
properties dialog, which is not easy to work with at all.)
Pre-creation:
DefaultMutableTreeNode top = new DefaultMutableTreeNode("Scenario");
createSideMenu(top);
Custom creation code:
new javax.swing.JTree(top);
Now I can just edit the "createSideMenu()" method if I need to change
anything.
I think there's a way to update the JFrame when one of it's components
is modified, but I haven't investigated it yet. The code above goes
around the problem by making the tree correctly right from the beginning.
Good luck.