Package io.github.jonestimd.swing.table
Class CompositeCellEditor<T>
- java.lang.Object
-
- javax.swing.AbstractCellEditor
-
- io.github.jonestimd.swing.table.CompositeCellEditor<T>
-
- Type Parameters:
T
- class of the table cell value
- All Implemented Interfaces:
java.io.Serializable
,javax.swing.CellEditor
,javax.swing.table.TableCellEditor
public abstract class CompositeCellEditor<T> extends javax.swing.AbstractCellEditor implements javax.swing.table.TableCellEditor
Base class for Cell editors with multiple input fields. This class handles the keyboard navigation between the fields. For compatibility withChangeBufferTableModel
, editing is performed on a copy of the table cell value.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CompositeCellEditor(java.util.function.Function<T,T> copyFunction)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addFields(javax.swing.JComponent... fields)
Add nested input fields for the table cell editor.T
getCellEditorValue()
protected abstract int
getInitialFocus()
java.awt.Component
getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
Creates a copy of the table cell value and initializes the input fields.protected abstract void
prepareEditor(javax.swing.JTable table, T value, boolean isSelected, int row, int column)
Initializes the nested input fields based on the table cell value.protected abstract void
updateCellEditorValue(T bean)
Updates the bean with the field values of the editor.-
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
-
-
-
-
Method Detail
-
addFields
protected void addFields(javax.swing.JComponent... fields)
Add nested input fields for the table cell editor.
-
getTableCellEditorComponent
public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
Creates a copy of the table cell value and initializes the input fields.- Specified by:
getTableCellEditorComponent
in interfacejavax.swing.table.TableCellEditor
-
getInitialFocus
protected abstract int getInitialFocus()
- Returns:
- the index of the nested input field to receive focus when editing starts.
-
prepareEditor
protected abstract void prepareEditor(javax.swing.JTable table, T value, boolean isSelected, int row, int column)
Initializes the nested input fields based on the table cell value.
-
getCellEditorValue
public T getCellEditorValue()
- Specified by:
getCellEditorValue
in interfacejavax.swing.CellEditor
-
updateCellEditorValue
protected abstract void updateCellEditorValue(T bean)
Updates the bean with the field values of the editor.- Parameters:
bean
- a copy of the table cell value (seegetTableCellEditorComponent(JTable, Object, boolean, int, int)
)
-
-