Action from KeyBinding don't execute on a JTable cell

早过忘川 提交于 2019-12-13 04:23:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!