// The following code saves the current value in the cell being edited
// and stops the editing process:
if (table.getCellEditor() != null) {
table.getCellEditor().stopCellEditing();
}
// The following code discards any changes made by the user and stops
// the editing process:
if (table.getCellEditor() != null) {
table.getCellEditor().cancelCellEditing();
}