Custom TreeModel
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Wednesday, December 19, 2001 01:03 PM

I have a custom TreeModel representing the nodes of a JTree. It works fine; if certain attributes of the nodes change, and those changes warrant a change in the GUI, I am able to make those changes appear. However, if I change the structure of the model -- by removing a node, for example -- then the model is correctly changed, but the JTree does not reflect those changes. I know that I need to fire an event of some sort, but none of the JTree fire* methods seem appropriate. (I need something like JTree.nodesRemoved().) I'm uncertain how to communicate those changes to the tree. (It seems to me that it should be done automatically, but that's just how I'd do it.) Any suggestions? Thanks.    More>>

I have a custom TreeModel representing the nodes of a JTree. It works fine; if certain attributes of the nodes change, and those changes warrant a change in the GUI, I am able to make those changes appear.

However, if I change the structure of the model -- by removing a node, for example -- then the model is correctly changed, but the JTree does not reflect those changes.

I know that I need to fire an event of some sort, but none of the JTree fire* methods seem appropriate. (I need something like JTree.nodesRemoved().)

I'm uncertain how to communicate those changes to the tree. (It seems to me that it should be done automatically, but that's just how I'd do it.)

Any suggestions?

Thanks.

   <<Less

Re: Custom TreeModel

Posted By:   Linda_Xu  
Posted On:   Wednesday, December 19, 2001 01:17 PM

You should not fire method from JTree under this kind of situation. Here, use the DeafultTreeModel.reload(). You will see the refreshed tree structure
About | Sitemap | Contact