You can enter a cell in Jtable either by clicking on it or by going to it using the cursor keys / tabs. With defaultCellEditor and JtextField, if you use the cursor keys, the carriage is placed at the end of the existing text field, whereas if you double-click on the field, it will highlight the last word.
While spreadsheets seem to work (e.g. Open Office Calc) the same way for double clcking, but if you enter the field and start editing, the field is cleared, and the first character pressed becomes the first value in the field and so on.
I want my application to work just like a spreadsheet. Subclassing DefaultCellEditor and adding
final Caret caret = editField.getCaret();
caret.setDot(0);
editField.setText("");
I can make it work the way I want it when tabbing, but it also clears the double-click box that I don't need.
So, please, how can I determine if editing a cell is caused by a keyboard or mouse?
source
share