Search code examples
javajtreetreemodel

Java Custom TreeModel: Using treeStructureChanged()


I've built a custom TreeModel for my Java application and, as part of that, have set up my model to fire TreeModelListener events. The docs say to call treeStructureChanged() when the tree has drastically changed structure from a node down but I'm unclear what this means for actually using it. When should my TreeModel call treeStructureChanged()?


Solution

  • Taken from this link (site changed and link is wrong now)

    In order to notify a listener of multiple inserts and deletes, or to identify changes at multiple levels in the tree, you use treeStructureChanged() and use the simple, no-children TreeModelEvent. In this case, the path argument specifies a node in the tree that did not change, and which has all of the other changes below it.