2

I have a JTree who contain some object

These objects have some field,one of them is used to display the node in the jtree.

I search a way to when the value of this field is changed, node in the jtree change too.

Now, in the valueChanged method if i do:

tree.firePropertyChange(JTree.ROOT_VISIBLE_PROPERTY, !tree.isRootVisible(), tree.isRootVisible());

that work... but i need to click on the node to get it to work.

Any idea, to get the modification in the jtree when value is changed?

redfox26
  • 2,020
  • 4
  • 25
  • 33
  • Possible duplicates of Q&As [here](http://stackoverflow.com/q/12642792/230513) and [here](http://stackoverflow.com/q/11107984/230513); both have complete examples, and the latter illustrates a convenient key binding. Please edit your question to include an [sscce](http://sscce.org/) that exhibits the problem you describe. – trashgod Feb 17 '13 at 16:43
  • 1
    really not the same thing – redfox26 Feb 17 '13 at 16:55
  • Edit your question to reflect _how_ it's _really not the same thing_; I've cited two good examples from which you can construct your [sscce](http://sscce.org/). – trashgod Feb 17 '13 at 16:56

1 Answers1

0

Since I don't see the whole code, I have two guesses:

  1. I guess, you don't update the whole thing in the Swing-GUI-Thread, but somewhere else. Therefore the GUI has the values from the thread, but has no idea, to update as well the GUI due to the changes.I would guess, that first try to make the update in the AWTEventQUeue resp. SwingUtilities.
  2. I guess the update might not be appropriate, cause DefaultTreeModel#nodeChanged(javax.swing.tree.TreeNode) should work resp. is more appropriate.
LeO
  • 4,238
  • 4
  • 48
  • 88