Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: TableView

[115:7] extends: Control

The TableView class wraps the JavaFX TableView control, which displays data in a grid of rows and columns with sortable, resizable column headers. Each column is defined by a TableColumn that specifies the header label and a cell value factory that extracts the display value from each row object. TableView supports both row-based and cell-based selection modes, and exposes selection-change listeners for reacting when the user picks a row or cell. The tables below list every CSS property available to TableView, organized by the class level where each property is defined.

CSS Pseudo-classes -- TableView

Pseudo-class Description
cell-selection Applies when cell selection mode is active.
row-selection Applies when row selection mode is active.

CSS Properties -- TableView

Property Values Default Description
-fx-fixed-cell-size <size> -1 A value greater than zero sets a fixed cell size; -1 disables it and uses computed sizes.

CSS Properties -- Control

Property Values Default Description
-fx-skin <string> null Fully qualified class name of the Skin to use for rendering this control.
-fx-focus-traversable true | false true When true, the control participates in focus traversal via the keyboard Tab key. (Default is false for Accordion, ScrollPane.)

CSS Properties -- Region

Background fills

Property Values Default Description
-fx-background-color <paint> [, <paint>]* transparent One or more paint values for background fill layers, rendered back to front.
-fx-background-insets <size> or <t> <r> <b> <l> [, ...]* 0 0 0 0 Insets from the region edges for each background fill layer.
-fx-background-radius <size> [/ <size>]* [, ...]* 0 0 0 0 Corner radii for each background fill layer.

Background images

Property Values Default Description
-fx-background-image <uri> [, <uri>]* null One or more image URIs for background image layers.
-fx-background-position <bg-position> [, ...]* 0% 0% Position of each background image within the region. Accepts keywords or size values.
-fx-background-repeat <repeat-style> [, ...]* repeat repeat Tiling behavior for each background image. Values: repeat, no-repeat, round, space applied per axis.
-fx-background-size <bg-size> [, ...]* auto auto Dimensions for each background image. Supports cover, contain, stretch, or explicit sizes.

Stroked borders

Property Values Default Description
-fx-border-color <paint> or <t> <r> <b> <l> [, ...]* null Paint colors for the border stroke layers.
-fx-border-insets <size> or <t> <r> <b> <l> [, ...]* null Insets from region edges for each border layer.
-fx-border-radius <size> [, ...]* null Corner radii for border stroke layers.
-fx-border-style <border-style> [, ...]* null Border line style (solid, dotted, dashed) plus phase and line cap/join options per layer.
-fx-border-width <size> or <t> <r> <b> <l> [, ...]* null Thickness of each border stroke layer, per side.

Border images

Property Values Default Description
-fx-border-image-source <uri> [, <uri>]* null Image URIs used to paint the border.
-fx-border-image-insets <size> or <t> <r> <b> <l> [, ...]* 0 0 0 0 Insets for each border image layer.
-fx-border-image-repeat <repeat-style> [, ...]* repeat repeat Tiling behavior for each border image.
-fx-border-image-slice <size> or <t> <r> <b> <l> [fill] [, ...]* 100% Divides each border image into nine regions. Adding fill preserves the center region.
-fx-border-image-width <size> or <t> <r> <b> <l> [, ...]* 1 1 1 1 Width of each border image slice per side.

Other Region properties

Property Values Default Description
-fx-padding <size> or <t> <r> <b> <l> 0 0 0 0 Interior padding between the region border and its content.
-fx-shape <string> null SVG path string that defines a custom clip shape for the region.
-fx-scale-shape true | false true When true, the shape is scaled to fit the region.
-fx-position-shape true | false true When true, the shape is centered within the region.
-fx-snap-to-pixel true | false true When true, positions and sizes are rounded to whole pixel boundaries.
-fx-min-width <size> -1 Minimum width. -1 uses the computed minimum.
-fx-pref-width <size> -1 Preferred width. -1 uses the computed preferred.
-fx-max-width <size> -1 Maximum width. -1 uses the computed maximum.
-fx-min-height <size> -1 Minimum height. -1 uses the computed minimum.
-fx-pref-height <size> -1 Preferred height. -1 uses the computed preferred.
-fx-max-height <size> -1 Maximum height. -1 uses the computed maximum.

CSS Properties -- Node

Property Values Default Description
-fx-blend-mode add | blue | color-burn | color-dodge | darken | difference | exclusion | green | hard-light | lighten | multiply | overlay | red | screen | soft-light | src-atop | src-in | src-out | src-over null Blend mode used when compositing this node with nodes beneath it.
-fx-cursor null | crosshair | default | hand | move | e-resize | h-resize | ne-resize | nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | v-resize | text | wait | <url> null (inherits) Mouse cursor shape shown when the pointer is over this node. Inherits from parent by default.
-fx-effect <effect> null A visual effect (e.g. DropShadow, InnerShadow) applied to the rendered node.
-fx-focus-traversable true | false false Whether this node participates in focus traversal. Overridden to true by Control.
-fx-view-order <number> 0 Adjusts rendering and hit-test order within the parent without changing the scene graph order.
-fx-opacity <number> [0.0 - 1.0] 1 Opacity of the node. 0 is fully transparent, 1 is fully opaque.
-fx-rotate <number> 0 Rotation angle in degrees applied around the node's center point. Positive values are clockwise.
-fx-scale-x <number> 1 Scale factor along the X axis about the node's center.
-fx-scale-y <number> 1 Scale factor along the Y axis about the node's center.
-fx-scale-z <number> 1 Scale factor along the Z axis about the node's center.
-fx-translate-x <number> 0 Translation offset along the X axis in pixels.
-fx-translate-y <number> 0 Translation offset along the Y axis in pixels.
-fx-translate-z <number> 0 Translation offset along the Z axis in pixels.
visibility visible | hidden | collapse | inherit visible Controls whether the node is rendered and participates in layout. collapse removes it from layout; hidden keeps the space.
-fx-managed true | false true When false, the parent layout does not manage this node's position or size.

Members

  • cols

Methods

  • TableView (Val = null)

    Initializes a new TableView instance with optional columns. If a list of columns is provided, they are set as the initial columns.

    • @p Val Val is either a list of columns to initialize or null for an empty table.
    • @r this object
  • setColumns (list Cols)

    Sets the columns for the TableView. Each element may be either a descriptor with display and colName fields (a simple, data-driven column bound to a row-map key) or a fully configured TableColumn wrapper. The two forms may be mixed in one call.

    • @p Cols is a list of column descriptors and/or TableColumn wrappers.
    • @r this object for chaining
  • addColumn (Column)

    Adds a single configured TableColumn to the table.

    • @p Column is a TableColumn wrapper (or column AJO).
    • @r this object for chaining
  • getColumn (string Display)

    Returns the column whose header text matches Display as a TableColumn wrapper, or null when no column matches. Works whether the column was built from a descriptor or added as a wrapper.

    • @p Display is the column header text.
    • @r A TableColumn wrapper, or null.
  • adoptColumn (Ajo)

  • setItems (list Rows)

    Sets the rows for the TableView.

    • @p Rows Rows is a list of row data to populate the table.
    • @r void
  • onChange (callback OnChange)

    Sets a callback function that triggers when the selected item changes.

    • @p OnChange The callback function for the selection change event.
    • @r this object for chaining
  • getSelected ()

    Retrieves the currently selected item in the TableView.

    • @r The selected item object, or null if no item is selected.
  • getSelectedIndex ()

    Returns the index of the currently selected row.

    • @r An int with the selected row index, or -1 if nothing is selected.
  • getSelectedRow ()

    Returns the entire selected row as a map or object.

    • @r The selected row object, or null if nothing is selected.
  • setPrefSize (double Width, double Height)

    Sets the preferred width and height of the TableView.

    • @p Width is a double with the preferred width in pixels.
    • @p Height is a double with the preferred height in pixels.
    • @r this object for chaining
  • setId (string Id)

    Sets the CSS id of this TableView node.

    • @p Id is a string with the CSS id.
    • @r this object for chaining
  • setColumnResizePolicy (string Policy)

    Sets the column resize policy for the TableView.

    • @p Policy is a string: CONSTRAINED_RESIZE_POLICY or UNCONSTRAINED_RESIZE_POLICY.
    • @r this object for chaining
  • setPlaceholder (object NodeObj)

    Sets a placeholder node to display when the TableView has no items.

    • @p NodeObj is a Node object to use as the placeholder.
    • @r this object for chaining
  • setFixedCellSize (double Size)

    Sets a fixed height in pixels for every row cell in the TableView.

    • @p Size is a double with the fixed cell size, or -1 to use computed sizes.
    • @r this object for chaining
  • itemsProperty ()

    Returns the items ObjectProperty for binding.

    • @r An AJO around the ObjectProperty<ObservableList>.
  • getItems ()

    Returns the ObservableList of row items in the TableView.

    • @r An AJO around the ObservableList.
  • tableMenuButtonVisibleProperty ()

    Returns the tableMenuButtonVisible BooleanProperty for binding.

    • @r An AJO around the BooleanProperty.
  • setTableMenuButtonVisible (bool Value)

    Sets whether the table menu button is visible.

    • @p Value is a bool with true to show the menu button.
    • @r this object for chaining
  • isTableMenuButtonVisible ()

    Returns whether the table menu button is visible.

    • @r A bool with true if the menu button is shown.
  • getColumnResizePolicy ()

    Returns the current column resize policy callback.

    • @r An AJO around the Callback.
  • columnResizePolicyProperty ()

    Returns the columnResizePolicy ObjectProperty for binding.

    • @r An AJO around the ObjectProperty.
  • setRowFactory (callback Factory)

    Sets a callback that creates each TableRow.

    • @p Factory is a callback that receives a TableView and returns a TableRow.
    • @r this object for chaining
  • placeholderProperty ()

    Returns the placeholder ObjectProperty for binding.

    • @r An AJO around the ObjectProperty.
  • getPlaceholder ()

    Returns the current placeholder node shown when the table is empty.

    • @r An AJO around the Node, or null.
  • selectionModelProperty ()

    Returns the selectionModel ObjectProperty for binding.

    • @r An AJO around the ObjectProperty.
  • setSelectionModel (object Model)

    Sets the selection model for the TableView.

    • @p Model is an AJO around a TableView.TableViewSelectionModel.
    • @r this object for chaining
  • setFocusModel (object Model)

    Sets the focus model for the TableView.

    • @p Model is an AJO around a TableView.TableViewFocusModel.
    • @r this object for chaining
  • focusModelProperty ()

    Returns the focusModel ObjectProperty for binding.

    • @r An AJO around the ObjectProperty.
  • setEditable (bool Value)

    Sets whether the table is editable.

    • @p Value is a bool with true to allow cell editing.
    • @r this object for chaining
  • isEditable ()

    Returns whether the table is editable.

    • @r A bool with true if editable.
  • editableProperty ()

    Returns the editable BooleanProperty for binding.

    • @r An AJO around the BooleanProperty.
  • getFixedCellSize ()

    Returns the current fixed cell size.

    • @r A double with the fixed cell size in pixels.
  • fixedCellSizeProperty ()

    Returns the fixedCellSize DoubleProperty for binding.

    • @r An AJO around the DoubleProperty.
  • getEditingCell ()

    Returns the cell position currently being edited.

    • @r An AJO around the TablePosition, or null.
  • editingCellProperty ()

    Returns the editingCell ReadOnlyObjectProperty for binding.

    • @r An AJO around the ReadOnlyObjectProperty.
  • getComparator ()

    Returns the comparator used to sort the table rows.

    • @r An AJO around the Comparator.
  • comparatorProperty ()

    Returns the comparator ReadOnlyObjectProperty for binding.

    • @r An AJO around the ReadOnlyObjectProperty.
  • setSortPolicy (callback Policy)

    Sets a callback that performs sorting on the table.

    • @p Policy is a callback that receives a TableView and returns a Boolean.
    • @r this object for chaining
  • setOnSort (callback Cb)

    Sets a callback that fires when the table is sorted.

    • @p Cb is a callback receiving a SortEvent.
    • @r this object for chaining
  • getOnSort ()

    Returns the current on-sort event handler.

    • @r An AJO around the EventHandler, or null.
  • onSortProperty ()

    Returns the onSort ObjectProperty for binding.

    • @r An AJO around the ObjectProperty.
  • getColumns ()

    Returns the table columns as TableColumn wrappers.

    • @r A list of TableColumn wrappers.
  • getColumnsRaw ()

    Returns the raw ObservableList of columns.

    • @r An AJO around the ObservableList.
  • getSortOrder ()

    Returns the columns that participate in sorting, in priority order, as TableColumn wrappers.

    • @r A list of TableColumn wrappers (empty when no sort is set).
  • getSortOrderRaw ()

    Returns the raw ObservableList of sort-order columns.

    • @r An AJO around the ObservableList.
  • sortBy (string Display, SortType)

    Sorts the table by the column with the given header text, setting its sort direction and making it the active sort column. This is the easy one-call sort. For multi-column sorts, use addToSortOrder then sort.

    • @p Display is the header text of the column to sort by.
    • @p SortType is an fxsorttype value or name string ("ASCENDING" or "DESCENDING").
    • @r this object for chaining
  • clearSort ()

    Clears all sorting, returning the table to its unsorted order.

    • @r this object for chaining
  • addToSortOrder (Column)

    Adds a column to the sort order without clearing the existing sort, for multi-column sorting. Set each column's sort type first, then call sort.

    • @p Column is a TableColumn wrapper (or column AJO).
    • @r this object for chaining
  • removeFromSortOrder (Column)

    Removes a column from the sort order.

    • @p Column is a TableColumn wrapper (or column AJO).
    • @r this object for chaining
  • scrollTo (int Index)

    Scrolls the table so the row at the given index is visible.

    • @p Index is an int with the row index.
    • @r this object for chaining
  • setOnScrollTo (callback Cb)

    Sets a callback that fires when scrollTo(int) is called.

    • @p Cb is a callback receiving a ScrollToEvent.
    • @r this object for chaining
  • getOnScrollTo ()

    Returns the current on-scrollTo event handler.

    • @r An AJO around the EventHandler, or null.
  • onScrollToProperty ()

    Returns the onScrollTo ObjectProperty for binding.

    • @r An AJO around the ObjectProperty.
  • scrollToColumn (object Col)

    Scrolls the table so the given column is visible.

    • @p Col is an AJO around a TableColumn.
    • @r this object for chaining
  • scrollToColumnIndex (int Index)

    Scrolls the table so the column at the given index is visible.

    • @p Index is an int with the column index.
    • @r this object for chaining
  • setOnScrollToColumn (callback Cb)

    Sets a callback that fires when scrollToColumn is called.

    • @p Cb is a callback receiving a ScrollToEvent.
    • @r this object for chaining
  • getOnScrollToColumn ()

    Returns the current on-scrollToColumn event handler.

    • @r An AJO around the EventHandler, or null.
  • onScrollToColumnProperty ()

    Returns the onScrollToColumn ObjectProperty for binding.

    • @r An AJO around the ObjectProperty.
  • resizeColumn (object Col, double Delta)

    Resizes the given column by the specified delta width.

    • @p Col is an AJO around a TableColumn.
    • @p Delta is a double with the width change in pixels.
    • @r A bool with true if the resize succeeded.
  • edit (int Row, object Col)

    Starts editing the cell at the given row index and column.

    • @p Row is an int with the row index.
    • @p Col is an AJO around the TableColumn.
    • @r this object for chaining
  • getVisibleLeafColumns ()

    Returns the ObservableList of currently visible leaf columns.

    • @r An AJO around the ObservableList.
  • getVisibleLeafIndex (object Col)

    Returns the index of the given column within the visible leaf columns.

    • @p Col is an AJO around a TableColumn.
    • @r An int with the index, or -1 if not visible.
  • getVisibleLeafColumn (int Index)

    Returns the visible leaf column at the given index.

    • @p Index is an int with the column index.
    • @r An AJO around the TableColumn, or null.
  • sort ()

    Sorts the table rows using the current sort order and comparator.

    • @r this object for chaining
  • refresh ()

    Refreshes the table so all visible cells are redrawn.

    • @r this object for chaining
  • getControlCssMetaData ()

    Returns the CSS metadata for this control's styleable properties.

    • @r A list of CssMetaData entries.
  • getSelectionModel ()

    Internal method to get the selection model for the TableView.

    • @r The selection model for managing item selection.
  • onCellValueFactoryCall (Param)

    Internal method for handling cell value factory calls for columns. This method provides cell data based on row values and column names.

    • @p Param Param is an object passed to retrieve column and row information.
    • @r A wrapper containing the value for the requested cell.
  • getFocusModel ()

    Returns the focus model that tracks which cell or row has focus.

    • @r An AJO wrapping javafx.scene.control.TableView.TableViewFocusModel.
  • getRowFactory ()

    Returns the row factory used to create each table row.

    • @r An AJO wrapping the row factory Callback, or null when the default is used.
  • rowFactoryProperty ()

    Returns the ObjectProperty backing the row factory.

    • @r An AJO wrapping ObjectProperty.
  • getSortPolicy ()

    Returns the sort policy that decides how the table is sorted.

    • @r An AJO wrapping the sort policy Callback.
  • sortPolicyProperty ()

    Returns the ObjectProperty backing the sort policy.

    • @r An AJO wrapping ObjectProperty.