问题
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