• Post Reply Bookmark Topic Watch Topic
  • New Topic

Replacing an existing JTree  RSS feed

 
Sonny Pondrom
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I have a working model of a JTree that I want to let the user change. I have referenced the new tree, but the old tree is not being replaced. Do I need to add the tree to its container again?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't have to completely rebuild the tree and add it to the container again... just make changes through the Tree Model... Especially take a look at DefaultTreeModel in the JavaDocs. You have methods like insertNodeInto(), nodeChanged(), nodesChanged(), nodeStructureChanged(), nodesWereInserted(), nodesWereRemoved(), reload(), etc. to modify the tree through the model.
 
Sonny Pondrom
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
I was wondering which is better if the entire tree is replaced, reload() or nodesChanged()with the root node as the argument?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!