Package io.github.jonestimd.swing.table
Class PopupListTableCellEditor<T>
- java.lang.Object
-
- javax.swing.AbstractCellEditor
-
- io.github.jonestimd.swing.table.PopupTableCellEditor
-
- io.github.jonestimd.swing.table.PopupListTableCellEditor<T>
-
- Type Parameters:
T- the type of the list items
- All Implemented Interfaces:
java.io.Serializable,javax.swing.CellEditor,javax.swing.table.TableCellEditor
public class PopupListTableCellEditor<T> extends PopupTableCellEditor
A table cell editor that displays a popup with aListFieldfor editing a list of values.MultiSelectTableCellRenderercan be used to render the list.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPopupListTableCellEditor.Builder<T>
-
Constructor Summary
Constructors Constructor Description PopupListTableCellEditor(java.util.function.Function<T,java.lang.String> format, java.util.function.Function<java.lang.String,T> parser, ListField.ItemValidator validator, javax.swing.text.Highlighter.HighlightPainter errorPainter, int rows)Create aPopupListTableCellEditor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> PopupListTableCellEditor.Builder<T>builder(java.util.function.Function<T,java.lang.String> format, java.util.function.Function<java.lang.String,T> parser)Create a builder for creating a newPopupListTableCellEditor.protected java.awt.WindowcreateWindow(java.awt.Window owner)Create the popup window.java.lang.ObjectgetCellEditorValue()java.awt.ComponentgetTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)protected voidshowPopup()Show the popup window.booleanstopCellEditing()Overridden to prevent closing the editor if it contains invalid items.-
Methods inherited from class io.github.jonestimd.swing.table.PopupTableCellEditor
fireEditingCanceled, fireEditingStopped, getPopupLocation, getTableCellSize, hidePopup
-
Methods inherited from class javax.swing.AbstractCellEditor
addCellEditorListener, cancelCellEditing, getCellEditorListeners, isCellEditable, removeCellEditorListener, shouldSelectCell
-
-
-
-
Field Detail
-
textArea
protected final ListField textArea
-
-
Constructor Detail
-
PopupListTableCellEditor
public PopupListTableCellEditor(java.util.function.Function<T,java.lang.String> format, java.util.function.Function<java.lang.String,T> parser, ListField.ItemValidator validator, javax.swing.text.Highlighter.HighlightPainter errorPainter, int rows)
Create aPopupListTableCellEditor.- Parameters:
format- a function for formatting the list itemsparser- a function for parsing a list item from a stringvalidator- a validator for items in the popup editorerrorPainter- a highlighter for indicating errors in the popup editorrows- the number of rows to display in the popup editor
-
-
Method Detail
-
createWindow
protected java.awt.Window createWindow(java.awt.Window owner)
Description copied from class:PopupTableCellEditorCreate the popup window.- Specified by:
createWindowin classPopupTableCellEditor- Parameters:
owner- the window containing the table
-
stopCellEditing
public boolean stopCellEditing()
Overridden to prevent closing the editor if it contains invalid items.- Specified by:
stopCellEditingin interfacejavax.swing.CellEditor- Overrides:
stopCellEditingin classjavax.swing.AbstractCellEditor- Returns:
- false if the editor contains invalid items
-
getTableCellEditorComponent
public java.awt.Component getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)- Specified by:
getTableCellEditorComponentin interfacejavax.swing.table.TableCellEditor- Overrides:
getTableCellEditorComponentin classPopupTableCellEditor
-
getCellEditorValue
public java.lang.Object getCellEditorValue()
-
showPopup
protected void showPopup()
Description copied from class:PopupTableCellEditorShow the popup window.- Overrides:
showPopupin classPopupTableCellEditor
-
builder
public static <T> PopupListTableCellEditor.Builder<T> builder(java.util.function.Function<T,java.lang.String> format, java.util.function.Function<java.lang.String,T> parser)
Create a builder for creating a newPopupListTableCellEditor.- Type Parameters:
T- the type of the list items- Parameters:
format- a function for formatting the list itemsparser- a function for parsing a list item from a string
-
-