Reputation: 5715
I've got a JTree
with a custom TreeModel
and a custom TreeCellEditor
displaying (for now) a JComboBox
through the getTreeCellEditorComponent()
override. The tree is displayed properly, with the nodes going into edit mode and displaying the JComboBox
when I click on them.
Whenever I edit a node, changing the value from the dropdown, and then proceed to select another node from the three, I can see the TreeCellEditor
's cancelCellEditing()
being triggered.
What's the "correct" way to stop editing in stead of cancelling it, thus (hopefully?) making sure the model's valueForPathChanged()
get's triggered?
Upvotes: 1
Views: 289
Reputation: 5715
After further investigation in the source code I found the answer inside the JTree class:
Setting JTree#setInvokesStopCellEditing(true)
means editing is stopped in stead of cancelled whenever I change focus from one node to another. This also means my TreeModel#valueForPathChanged()
gets called.
Upvotes: 2