aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to refresh my tree when the model changes. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to refresh my tree when the model changes." Watch "How to refresh my tree when the model changes." New topic
Author

How to refresh my tree when the model changes.

Richard Johnson
Greenhorn

Joined: Mar 30, 2002
Posts: 10
Hi,
I have written my own custom tree model. I create the JTree and pass the model as parameter then show the JTree in a scrollpane.
There is a button to repopulate the tree model. My question is when I hit this the model is repopulated, but the UI does not reflect the changes even after calling revalidate.
What is the best way to detect the changes and update the JTree/UI properly when the whole tree model (except the root node) is regenerated? Should I be firing some sort of event from the tree model after it's regenerated or something?
Thanks for the assistance.
Rich.
Andy Nimmo
Greenhorn

Joined: Mar 30, 2003
Posts: 14
Richard,
At what point in your code are you calling the validate( ) method? Also, which components validate( ) method are you calling?
Maybe post a little code in a reply so we can see what you're doing easier.
Cheers,
Andy.
"I Code, Therefore I Am"
Richard Johnson
Greenhorn

Joined: Mar 30, 2002
Posts: 10
okay sure, this will be very trimmed down from the actual code. The abstract view is just a fancy JPanel that does various other interesting things I use in my application framework, I just call revalidate on it:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to refresh my tree when the model changes.
 
Similar Threads
JTree reload question, AGAIN
JTree
JTree errors with treeModel.nodeChanged()
JTree & Database
JTree refresh, with new TreeModel