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.TableCellEditorBase 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 protectedCompositeCellEditor(java.util.function.Function<T,T> copyFunction)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidaddFields(javax.swing.JComponent... fields)Add nested input fields for the table cell editor.TgetCellEditorValue()protected abstract intgetInitialFocus()java.awt.ComponentgetTableCellEditorComponent(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 voidprepareEditor(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 voidupdateCellEditorValue(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:
getTableCellEditorComponentin 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:
getCellEditorValuein 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))
-
-