Module is.codion.swing.common.ui
Class FilteredTable<R,C>
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
is.codion.swing.common.ui.component.table.FilteredTable<R,C>
- Type Parameters:
R
- the type representing rowsC
- the type used to identify columns
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,CellEditorListener
,ListSelectionListener
,RowSorterListener
,TableColumnModelListener
,TableModelListener
,Scrollable
A JTable implementation for
FilteredTableModel
.
Note that for the table header to display you must add this table to a JScrollPane.
For instances use the builder builder(FilteredTableModel)
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A builder for aFilteredTable
static enum
Specifies whether to center the scrolled to row and or column.static enum
The available keyboard shortcuts.Nested classes/interfaces inherited from class javax.swing.JTable
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final PropertyValue<Boolean>
Specifies whether columns can be rearranged in tables
Value type: Boolean
Default value: truestatic final PropertyValue<Integer>
Specifies the default table column resize mode for tables in the application
Value type: Integer (JTable.AUTO_RESIZE_*)
Default value:JTable.AUTO_RESIZE_OFF
static final KeyboardShortcuts<FilteredTable.KeyboardShortcut>
The default keyboard shortcut keyStrokes.Fields inherited from class javax.swing.JTable
AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Method Summary
Modifier and TypeMethodDescriptionvoid
autoStartsEdit
(boolean autoStartsEdit) A convenience method for setting the client property 'JTable.autoStartsEdit'.static <R,
C> FilteredTable.Builder<R, C> builder
(FilteredTableModel<R, C> tableModel) Instantiates a newFilteredTable.Builder
using the given modelboolean
cellVisible
(int row, int column) Returns true if the given cell is visible.void
Copies the contents of the selected cell to the clipboard.void
Copies the table data as a TAB delimited string, with header, to the clipboard.void
Copies the table data as a TAB delimited string, with header, to the clipboard.protected JTableHeader
getModel()
void
scrollToColumn
(C columnIdentifier) Scrolls horizontally so that the column identified by the given identifier becomes visible.void
scrollToCoordinate
(int row, int column, FilteredTable.CenterOnScroll centerOnScroll) Scrolls to the given coordinate.void
Displays a dialog for selecting the column auto-resize modevoid
Shows a dialog for selecting which columns to displayvoid
setColumnModel
(TableColumnModel columnModel) void
setModel
(TableModel dataModel) void
setSelectionMode
(int selectionMode) void
setSelectionModel
(ListSelectionModel selectionModel) void
updateUI()
Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getDropLocation, getDropMode, getEditingColumn, getEditingRow, getEditorComponent, getFillsViewportHeight, getGridColor, getIntercellSpacing, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, print, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, tableChanged, unconfigureEnclosingScrollPane, valueChanged
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
AUTO_RESIZE_MODE
Specifies the default table column resize mode for tables in the application
Value type: Integer (JTable.AUTO_RESIZE_*)
Default value:JTable.AUTO_RESIZE_OFF
-
ALLOW_COLUMN_REORDERING
Specifies whether columns can be rearranged in tables
Value type: Boolean
Default value: true -
DEFAULT_KEYBOARD_SHORTCUTS
The default keyboard shortcut keyStrokes.
-
-
Method Details
-
updateUI
public void updateUI() -
getModel
-
getColumnModel
- Overrides:
getColumnModel
in classJTable
-
setModel
-
setColumnModel
- Overrides:
setColumnModel
in classJTable
-
setSelectionModel
- Overrides:
setSelectionModel
in classJTable
-
filterPanel
- Returns:
- the filter panel
-
searchField
- Returns:
- the search field
-
doubleClickAction
- Returns:
- the Value controlling the action to perform when a double click is performed on the table, null for no double click action
-
sortingEnabled
- Returns:
- the State controlling whether sorting via the table header is enabled
-
scrollToSelectedItem
- Returns:
- the State controlling whether the JTable instance scrolls automatically to the coordinate of the item selected in the underlying table model
-
centerOnScroll
- Returns:
- the Value controlling the scrolling behaviour when scrolling to the selected row/column
-
setSelectionMode
public void setSelectionMode(int selectionMode) - Overrides:
setSelectionMode
in classJTable
-
selectColumns
public void selectColumns()Shows a dialog for selecting which columns to display -
selectAutoResizeMode
public void selectAutoResizeMode()Displays a dialog for selecting the column auto-resize mode -
cellVisible
public boolean cellVisible(int row, int column) Returns true if the given cell is visible.- Parameters:
row
- the rowcolumn
- the column- Returns:
- true if this table is contained in a scrollpanel and the cell with the given coordinates is visible.
-
scrollToColumn
Scrolls horizontally so that the column identified by the given identifier becomes visible. Has no effect if this table is not contained in a scrollpanel.- Parameters:
columnIdentifier
- the column identifier
-
scrollToCoordinate
Scrolls to the given coordinate. Has no effect if this table is not contained in a scrollpanel.- Parameters:
row
- the rowcolumn
- the columncenterOnScroll
- specifies whether to center the selected row and or column
-
copySelectedCell
public void copySelectedCell()Copies the contents of the selected cell to the clipboard. -
copyToClipboard
public void copyToClipboard()Copies the table data as a TAB delimited string, with header, to the clipboard. -
copySelectedToClipboard
public void copySelectedToClipboard()Copies the table data as a TAB delimited string, with header, to the clipboard. -
createSelectColumnsControl
- Returns:
- a control for showing the column selection dialog
-
createToggleColumnsControls
- Returns:
- Controls containing
ToggleControl
s for showing/hiding columns.
-
createResetColumnsControl
- Returns:
- a Control for resetting the columns to their original location and visibility
-
createAutoResizeModeControl
- Returns:
- a Control for selecting the auto-resize mode
-
createSingleSelectionModeControl
- Returns:
- a ToggleControl for toggling the table selection mode (single or multiple)
-
autoStartsEdit
public void autoStartsEdit(boolean autoStartsEdit) A convenience method for setting the client property 'JTable.autoStartsEdit'.- Parameters:
autoStartsEdit
- the value
-
doubleClickEvent
- Returns:
- an observer notified each time the table is double-clicked
-
builder
Instantiates a newFilteredTable.Builder
using the given model- Type Parameters:
R
- the type representing rowsC
- the type used to identify columns- Parameters:
tableModel
- the table model- Returns:
- a new
FilteredTable.Builder
instance
-
createDefaultTableHeader
- Overrides:
createDefaultTableHeader
in classJTable
-