• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTree live update  RSS feed

 
james barrett
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

i am using a JTree to list a contact list on a gui, this list is populated fine when the gui is executed, but i cant get it to update dynamically if a new user is added to the list. I have read about attatching actionlisteners to the tree and using the to call a .revalidate() method, but i am updating the list of contacts from another class, not a button.

so two questions, how can i use another class to fire off an event? if its even possible. and secondly, is there a better way to be updating the JTree?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
((DefaultTreeModel)tree.getModel()).reload();
 
james barrett
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the fast reply, but i have already tried that, and the tree isnt updating. This tree is wrapped up in a contentPane, but i have tried updating that and also no joy.

Strangly it wont go away when i call the dispose() method on it either. perhapse the entire implimentation is wrong.

thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!