Make sure you enable the selection in your custom table instance, for example, below:
table.setColumnSelectionAllowed(true);
table.setRowSelectionAllowed(true);
In this case, as a rule, the call table.editCellAt(row, col);starts editing. Example:
JTable myTable = new JTable(rows, cols);
myTable.setColumnSelectionAllowed(true);
myTable.setRowSelectionAllowed(true);
and somewhere else. where change is required
boolean wasEditStarted = table.editCellAt(row, col);
if (wasEditStarted) {
table.changeSelection(row, col, false, false);
}
source
share