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
Nested ClassesModifier and TypeClassDescriptionstatic interfaceA builder for aFilteredTablestatic enumSpecifies whether to center the scrolled to row and or column.Nested classes/interfaces inherited from class javax.swing.JTable
JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintModeNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final is.codion.common.property.PropertyValue<Boolean>Specifies whether columns can be rearranged in tables
Value type: Boolean
Default value: truestatic final is.codion.common.property.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_OFFFields 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, tableHeaderFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDoubleClickListener(Consumer<MouseEvent> listener) static <R,C> FilteredTable.Builder<R, C> builder(is.codion.swing.common.model.component.table.FilteredTableModel<R, C> tableModel) Instantiates a newFilteredTable.Builderusing the given modelbooleancellVisible(int row, int column) Returns true if the given cell is visible.is.codion.common.value.Value<FilteredTable.CenterOnScroll>voidCopies the table data as a TAB delimited string, with header, to the clipboard.voidCopies the contents of the selected cell to the clipboard.is.codion.common.value.Value<Action>is.codion.swing.common.model.component.table.FilteredTableColumnModel<C>getModel()voidremoveDoubleClickListener(Consumer<MouseEvent> listener) voidscrollToColumn(C columnIdentifier) Scrolls horizontally so that the column identified by the given identifier becomes visible.voidscrollToCoordinate(int row, int column, FilteredTable.CenterOnScroll centerOnScroll) Scrolls to the given coordinate.is.codion.common.state.StatevoidDisplays a dialog for selecting the column auto-resize modevoidShows a dialog for selecting which columns to displayvoidsetAutoStartsEdit(boolean autoStartsEdit) A convenience method for setting the client property 'JTable.autoStartsEdit'.voidsetColumnModel(TableColumnModel columnModel) voidsetModel(TableModel dataModel) voidsetSelectionMode(int selectionMode) voidsetSelectionModel(ListSelectionModel selectionModel) is.codion.common.state.StatevoidupdateUI()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, createDefaultTableHeader, 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, valueChangedMethods 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, updateMethods 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, validateTreeMethods 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
-
-
Method Details
-
updateUI
public void updateUI() -
getModel
-
getColumnModel
- Overrides:
getColumnModelin classJTable
-
setModel
-
setColumnModel
- Overrides:
setColumnModelin classJTable
-
setSelectionModel
- Overrides:
setSelectionModelin 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
public is.codion.common.state.State sortingEnabled()- Returns:
- the State controlling whether sorting via the table header is enabled
-
scrollToSelectedItem
public is.codion.common.state.State 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:
setSelectionModein 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. -
copyRowsAsTabDelimitedString
public void copyRowsAsTabDelimitedString()Copies the table data as a TAB delimited string, with header, to the clipboard. Note that if the selection is empty all rows are copied, otherwise only selected rows. -
createSelectColumnsControl
- Returns:
- a control for showing the column selection dialog
-
createToggleColumnsControls
- Returns:
- Controls containing
ToggleControls 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)
-
setAutoStartsEdit
public void setAutoStartsEdit(boolean autoStartsEdit) A convenience method for setting the client property 'JTable.autoStartsEdit'.- Parameters:
autoStartsEdit- the value
-
addDoubleClickListener
- Parameters:
listener- a listener notified each time the table is double-clicked
-
removeDoubleClickListener
- Parameters:
listener- the listener to remove
-
builder
public static <R,C> FilteredTable.Builder<R,C> builder(is.codion.swing.common.model.component.table.FilteredTableModel<R, C> tableModel) Instantiates a newFilteredTable.Builderusing 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.Builderinstance
-