I would like to use a JTable for editing a JTree, I extended DefaultTreeCellEditor and implemented isCellEditable getTreeCellEditorComponent, in getTreeCellEditorComponent I return a JTable. Everything works up to this point when a node is edited swing displays the JTable filled with the objects content however when editing is complete, valueForPathChanged of DefaultTreeModel never gets called. If I use a text field for editing which is the default everything works fine.
I would like to use a JTable for editing a JTree, I extended DefaultTreeCellEditor
Share
JTextFieldhas anotifyAction, named "notify-field-accept" and typically bound toKeyEvent.VK_ENTER, that signals theCellEditortostopEditing()and ultimately invokes theDefaultTreeCellEditormethod,valueForPathChanged().It’s not clear how you indicate that editing is complete for your
JTable. You should be able to do something similar with theJTextFieldin aCellEditorListenerthat is added to your custom editor viaaddCellEditorListener().Incidentally,
valueForPathChanged()mentions that "If you use custom user objects in the TreeModel you’re going to need to subclass this and set the user object of the changed node to something meaningful."