问题
im having a problem that is cause i CAN edit the cell when not having focus but when i press the bind key in the cell ("Enter"), action is not performed.
But when is has focus, action is performed correctly.
I only want to add the keybinding for that specific cell (row,col) , so i added to the textfield in the render.
May be im doing something bad.
回答1:
As you tab from cell to cell focus in still on the table. The editor is only invoked when you double click with the mouse or use F2 with the keyboard. While the cell is being edited, the text field (which is the default editor) has focus.
If you start typing on a cell text is added to the cell but I believe the default behaviour is for focus to remain on the table. However, I think you can change the default by using the following when you create the table:
table.setSurrendersFocusOnKeystroke(true);
来源:https://stackoverflow.com/questions/17281735/action-from-keybinding-dont-execute-on-a-jtable-cell