Posted CellEditor.
import java.awt.Component;
import javax.swing.AbstractCellEditor;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.TableCellEditor;
public class UserCellEditor extends AbstractCellEditor
implements TableCellEditor {
JComponent component = new JTextField();
public Object getCellEditorValue() {
return ((JTextField) component).getText();
}
public Component getTableCellEditorComponent(JTable table,
Object value, boolean isSelected, int row, int column) {
((JTextField) component).setText((String) value);
return component;
}
}
Then I call table method in such way:
UserTable.getColumnModel().getColumn(0).setCellEditor(new UserCellEditor());
The cell is being edited, but the result by pressing the Enter
key or move to another cell is not stored, it returns the original value.
Where am I wrong or what I'm doing wrong?