来自KeyBinding的操作不在JTable单元上执行 [英] Action from KeyBinding don't execute on a JTable cell

查看:106
本文介绍了来自KeyBinding的操作不在JTable单元上执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个问题,原因是当我没有焦点时可以编辑单元格,但是当我按单元格中的绑定键("Enter")时,将不执行操作.

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.

我只想为该特定单元格(row,col)添加键绑定,所以我将其添加到渲染器的文本字段中.

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.

推荐答案

当您从一个单元格切换到另一个单元格时,焦点仍停留在表格上.仅当您用鼠标双击或使用F2键盘时才调用编辑器.在编辑单元格时,文本字段(默认编辑器)具有焦点.

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);

这篇关于来自KeyBinding的操作不在JTable单元上执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆