swingjtablejtreejtreetable

JTreeTable model updating


I'm following the example of JTreeTable filesystem2 taken from the sun site http://java.sun.com/products/jfc/tsc/articles/treetable2/index.html#updating_the My problem is that I can't update my model (and then my JTreeTable)... In fact I create my model, I pass it to the JTreeTable and all work fine...but I need to modify the model... I've yet answer a similar question, but now I've changed my code, without find a solution.

The problem is when and how I have to call the method fireTreeNodesChanged()...in the example above is used the method getPath() to retrieve information about the root node...but this is a method of File class..not my case...

Does anyone have a link to a simple code which shows how create a TreeTabelModel (with objects as nodes) and how update it?


Solution

  • FileBrowser is a good example of modeling a hierarchical file system as a tree. While its TreeModel is implemented using DefaultTreeModel, an alternative FileTreeModel is shown here. As mentioned in How to Use Trees: Creating a Data Model "the TreeModel interface accepts any kind of object as a tree node."