Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: break focus cycle in jtable

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?

like image 385
Florian Ruh Avatar asked Dec 02 '25 09:12

Florian Ruh


1 Answers

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.

like image 178
trashgod Avatar answered Dec 03 '25 23:12

trashgod



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!