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 aListField
for editing a list of values.MultiSelectTableCellRenderer
can be used to render the list.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PopupListTableCellEditor.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.Window
createWindow(java.awt.Window owner)
Create the popup window.java.lang.Object
getCellEditorValue()
java.awt.Component
getTableCellEditorComponent(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
protected void
showPopup()
Show the popup window.boolean
stopCellEditing()
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:PopupTableCellEditor
Create the popup window.- Specified by:
createWindow
in 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:
stopCellEditing
in interfacejavax.swing.CellEditor
- Overrides:
stopCellEditing
in 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:
getTableCellEditorComponent
in interfacejavax.swing.table.TableCellEditor
- Overrides:
getTableCellEditorComponent
in classPopupTableCellEditor
-
getCellEditorValue
public java.lang.Object getCellEditorValue()
-
showPopup
protected void showPopup()
Description copied from class:PopupTableCellEditor
Show the popup window.- Overrides:
showPopup
in 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
-
-