Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Update JTree Node without firing ValueChanged

 
John Ryan
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
Hi,
I have implemented my own Tree Model which i use to manage the objects i am adding to the JTree. On the right hand side of my GUI i display the attributes of my tree nodes. These attributes including the node name, are editable. My problem is that when i change the node name on the right hand side of the GUI i update the user object corresponding to that node. I am then updating the GUI using model.reload. However this seems to fire off a valueChanged event on the TreeListener which is causing all sorts of problems for me ( It also means that the selected node is set to null. I do not want to lose my selected node). I do not want to change the selected node, but merely to update the GUI to reflect the new node name.
Because the valueChanged event is being fired i am getting a circular type of event handling where the selection of a node updates the right hand side, and then a change in one of the attributes causes the the selected node to change and again updates the right hand side. How do i prevent this?
Any suggestions appreciated....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic