This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTree not updating Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree not updating" Watch "JTree not updating" New topic
Author

JTree not updating

Rik Sweeney
Ranch Hand

Joined: Sep 04, 2001
Posts: 36
Hi,

I'm adding nodes to my JTree, but it is not being updated. If I add a node to the root, then the tree updates OK, but then if I add another, nothing happens. If I then add a node to the child of the node, then the tree updates OK and will show the node number as if all the other nodes have been added.

Anyway, here's the code



Does anyone know what I'm doing wrong?

Thanks

Richard
Andr� Latour
Greenhorn

Joined: May 22, 2006
Posts: 15
Hello Rik,

only an idea:

After you rebuild your tree, add the "new" rootElement to your DefaultTreeModel

something like this:



Regards
Andr�
[ May 23, 2006: Message edited by: Andr� Latour ]
Rik Sweeney
Ranch Hand

Joined: Sep 04, 2001
Posts: 36
Thanks for the suggestion. I had a quick look in the constructor and changed it to



This solved the problem!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTree not updating
 
Similar Threads
JTree not updating
JTree
Subtree in JTree
JTree - collapsePath issue
sorting node position in JTree