I have a JTable
with editable cells. When I click in a cell, it enters edit mode; the same happens when I\'m moving through cell using the directional arrows.
N
Use Key Bindings for this. Most Look & Feel implementations already bind F2 to the table's startEditing
action, but you add a different binding:
tree.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "startEditing");
This will effectively replace the previous binding of Enter to the table's selectNextRowCell
action.
Here is what i would do:
You can check in the keyPressed() method, if the user pressed the right button for editing. I'm not sure, if the normal (double click) editing is disabled in your table, then what happens, if you try to edit it programmatically, but if it doesn't work, then you can enable the editing on the selected cell, when the user presses the edit button, then when he/she finished, disable it again.