Question

I have problems in understanding how CellEditors work in Java.

I have a JTable with a model (extends AbstractTableModel). The JTable has its CellRenderer and CellEditor. The CellEditor only overrides isCellEditable() (one condition added).

How do the changes I made in one Cell go to the Model? Does the Model has to implement an CellEditorListener and react on stopEditing()?

I have read, that the changes would automatically be stored in the model. Is that true? If yes, how does it work? Do I have to react on tableChanged() then?

Please explain the way of the data, which have changed and at which steps I have to do something.

Thanks a lot!

Was it helpful?

Solution

The changes are applied to the model via the TableModel's .setValueAt() method. The JTable itself takes care of receiving the value returned by the CellEditor and passing it to the TableModel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top