Java: break focus cycle in jtable

流过昼夜 提交于 2020-01-03 22:57:23

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/17428615/java-break-focus-cycle-in-jtable

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