Click to See Complete Forum and Search --> : How do I refresh a JTree?


Splatt
September 22nd, 2000, 11:26 AM
I'm having problems getting a JTree to reflect changes made to it's nodes. Basically, my tree contains a JPanel at each node. If I add or take away objects to those JPanels it is correctly done in software (an eneumeration of all the components in a given pane lists what it should contain). For some reason the added components do not appear in the JTree. I'm assuming this is just a problem with refreshing/updating the display. I've tried invalidate/validate and update, but nothing seems to work. Is there something I'm overlooking?

Thanks!

"There's nothing more dangerous than a resourceful idiot." ---Dilbert

cpraveenbabu
September 29th, 2000, 04:54 AM
U can refresh a JTree by invoking
DefaultTreeModel.reload()

If everything is right with panels then the validate method should definitely work

Regards
Praveen



When going gets tough,
Tough gets going.

mjpell
September 29th, 2000, 02:19 PM
Are you wanting to refresh the data? or the painting of your tree?

I refreshed mine by setting the model to null. Then, my 'new' model is lazy initialized the next time the JTree requests data. this effectively refreshes both the data and the painting.

I created a button, who's action sets the model to null...

HOpe that helps,