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.
+1
A:
JTextField
has a notifyAction
, named "notify-field-accept" and typically bound to KeyEvent.VK_ENTER
, that signals the CellEditor
to stopEditing()
and ultimately invokes the DefaultTreeCellEditor
method, valueForPathChanged()
.
It's not clear how you indicate that editing is complete for your JTable
. You should be able to do something like JTextField
in a CellEditorListener
that is added to your custom editor via addCellEditorListener()
.
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."
trashgod
2010-08-08 14:53:18