Hi All, I am implementing TreeModel to buil a custom model to a JTree. My problem is when a Edit the Model (add,remove,change value of a Node ) my Tree does no refresh to present the accurate data. I have seen lots of example on the web, but each time people are using DefaultMutableTree .. to perform editing operation. I am writing an xml Editor that uses a DOM parser to read the data into a DOM that I display using a JTree. Then I sue a SAX 2 parser to validate the data against a schema and display errors in a different rendering. Now I need to enable the user to edit the xml DOM Tree in order to correct the file. Itried implementing a TreeModelListener class, but I have no idea of what kind of code should go into each method of the interface to get my tree updated. I really need help quicklly and would be greatefull of example with code samples:I read a lot about the theory but still not getting there Thanks.
Ok, DefaultMutableTreeNode is a long long word and I hate it too, but the class itself is really smart, because you can give this class your own object (setUserObject()). There you can take whatever you want, you simply have to implement the toString method in order to show it right. Of course, you can do all by your own by implementing TreeModel, but in my opinion it is better to use existing stuff like DefaultTreeModel and extending from that, because they will fire all events. I think, this could be your problem. After you are changing the model, maybe you forget to tell the tree, what happened?