Java:在jtable中打破焦点循环 [英] Java: break focus cycle in jtable
问题描述
我实现了ENTER,停止编辑单元格并将焦点传递给下一个单元格。但是,当我在最后一个单元格中按ENTER时,焦点周期使我跳到第一个单元格。但是我想继续在表外设置焦点到一个JButton。
我怎么能打破这个循环?
setCellSelectionEnabled()
应该允许你继续。根据需要使用 setDefaultButton()
,以便示例。 $ b
附录:除了 setDefaultButton()
之外,还可以在自定义的 Action
,如此处所示。
In my JTable, I want to edit all relevant cells like in Excel.
I implemented that ENTER stops editing the cell and transfers focus to the next cell. However, when I hit ENTER in the last cell, the focus cycle makes me jump to the fist cell. But I want to continue outside the table and set focus to a JButton.
How can I break this cycle?
JTable
is not a spreadsheet, but setCellSelectionEnabled()
should allow you to proceed. Use setDefaultButton()
as required, for example.
Addendum: In addition to setDefaultButton()
, you can evoke any desired action in your custom Action
, as shown here.
这篇关于Java:在jtable中打破焦点循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!