Skip to content
Advertisement

Jtree not shown on adding a node!

I have a static jtree in a scrollpane. And now iam trying to add child to jtree, it got added successfully. Now, the added node is not visible in the jtree.

Try 1: I have tried with model.reload()

JavaScript

Try 2: I have tried with tree.setModel() too…

JavaScript

Even then newly added child is not visible. but Its getting added in thr tree. I tested by printing the child. Suggest me a solution.

Advertisement

Answer

Simply try the following line:

JavaScript

Check this simple example. It works for me and shows both new nodes after the 5 seconds delay.

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement