JTable:双击应保留先前的选择
我有一个 JTable
,我可以在其中选择一个或多个单元格。我还想对双击做出反应,为选定的单元格执行一些额外的操作。但问题是,当用户双击时,选择更改为单击的单元格。但我想在双击时保留先前的选择,这样我就可以处理所有选定单元格的双击。
编辑:
与此问题相关:
Java:忽略双击上的单击?
但我希望,对于我的情况有一个更好/更简单的解决方案。
I have a JTable
where I can select one or more cells. I also want to react on double-click for doing some extra action for the selected cells. But the problem is, when the user double-clicks, the selection changes to the clicked cell. But I want to keep the prior selection on double-click, so I can handle the double-click for all selected cells.
EDIT:
Related to this question:
Java : ignore single click on double click?
But I hope, there is a better/easier solution for my case.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是,第一次单击时,第一个事件就会消失。稍后,第二次点击可能会出现,也可能不会出现。所以第一次点击事件确实什么都不知道。正如在建议的解决方案中,计时器可能会做的那样。
还可以做的是在第一次单击时不选择任何内容,但稍后调用一个特殊的选择事件。
并在处理双击/myRunnable 时真正的选择。但时机可能是不可避免的。
The problem is, that on the first click the first event goes out. A bit later the second click might come or not. So the first click event does know nothing. As in the proposed solution a timer might do.
What also might do is on the first click to select nothing, but invoke a special selection event a bit later.
and on handling the double click/myRunnable the true selection. Timing might be unavoidable though.
您可以使用 setClickCountToStart()对于 XxxCellEditor,我不了解您的 JTable
you can use setClickCountToStart() for XxxCellEditor, I don't know something about your JTable