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 rows
C - the type used to identify columns
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable

public final class FilteredTable<R,C> extends JTable
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:
  • Field Details

    • AUTO_RESIZE_MODE

      public static final PropertyValue<Integer> 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

      public static final PropertyValue<Boolean> ALLOW_COLUMN_REORDERING
      Specifies whether columns can be rearranged in tables
      Value type: Boolean
      Default value: true
    • DEFAULT_KEYBOARD_SHORTCUTS

      public static final KeyboardShortcuts<FilteredTable.KeyboardShortcut> DEFAULT_KEYBOARD_SHORTCUTS
      The default keyboard shortcut keyStrokes.
  • Method Details

    • updateUI

      public void updateUI()
      Overrides:
      updateUI in class JTable
    • getModel

      public FilteredTableModel<R,C> getModel()
      Overrides:
      getModel in class JTable
    • getColumnModel

      public FilteredTableColumnModel<C> getColumnModel()
      Overrides:
      getColumnModel in class JTable
    • setModel

      public void setModel(TableModel dataModel)
      Overrides:
      setModel in class JTable
    • setColumnModel

      public void setColumnModel(TableColumnModel columnModel)
      Overrides:
      setColumnModel in class JTable
    • setSelectionModel

      public void setSelectionModel(ListSelectionModel selectionModel)
      Overrides:
      setSelectionModel in class JTable
    • filterPanel

      public FilteredTableConditionPanel<C> filterPanel()
      Returns:
      the filter panel
    • searchField

      public JTextField searchField()
      Returns:
      the search field
    • doubleClickAction

      public Value<Action> 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 State sortingEnabled()
      Returns:
      the State controlling whether sorting via the table header is enabled
    • scrollToSelectedItem

      public 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

      public Value<FilteredTable.CenterOnScroll> centerOnScroll()
      Returns:
      the Value controlling the scrolling behaviour when scrolling to the selected row/column
    • setSelectionMode

      public void setSelectionMode(int selectionMode)
      Overrides:
      setSelectionMode in class JTable
    • 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 row
      column - the column
      Returns:
      true if this table is contained in a scrollpanel and the cell with the given coordinates is visible.
    • scrollToColumn

      public void scrollToColumn(C columnIdentifier)
      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

      public void scrollToCoordinate(int row, int column, FilteredTable.CenterOnScroll centerOnScroll)
      Scrolls to the given coordinate. Has no effect if this table is not contained in a scrollpanel.
      Parameters:
      row - the row
      column - the column
      centerOnScroll - 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

      public Control createSelectColumnsControl()
      Returns:
      a control for showing the column selection dialog
    • createToggleColumnsControls

      public Controls createToggleColumnsControls()
      Returns:
      Controls containing ToggleControls for showing/hiding columns.
    • createResetColumnsControl

      public Control createResetColumnsControl()
      Returns:
      a Control for resetting the columns to their original location and visibility
    • createAutoResizeModeControl

      public Control createAutoResizeModeControl()
      Returns:
      a Control for selecting the auto-resize mode
    • createSingleSelectionModeControl

      public ToggleControl 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

      public EventObserver<MouseEvent> doubleClickEvent()
      Returns:
      an observer notified each time the table is double-clicked
    • builder

      public static <R, C> FilteredTable.Builder<R,C> builder(FilteredTableModel<R,C> tableModel)
      Instantiates a new FilteredTable.Builder using the given model
      Type Parameters:
      R - the type representing rows
      C - the type used to identify columns
      Parameters:
      tableModel - the table model
      Returns:
      a new FilteredTable.Builder instance
    • createDefaultTableHeader

      protected JTableHeader createDefaultTableHeader()
      Overrides:
      createDefaultTableHeader in class JTable