Skip to main content

Overview

JTable is a feature-rich table component built on JavaFX TableView with advanced capabilities including:
  • Checkbox selection with header “select all” control
  • Built-in search and filtering across columns
  • Custom cell renderers for rich content
  • Row actions column with custom buttons/controls
  • Bulk actions toolbar for multi-row operations
  • CSV export functionality
  • Pagination with customizable items per page
  • Infinite scroll support
  • Empty state customization
  • Striped and dense visual modes

Constructor

JTable<T>()
constructor
Creates a new generic table for type T.

Basic Usage

JTable<User> table = new JTable<>();
table.setCheckable(true);
table.setSearchable(true);
table.setStriped(true);
table.addColumn("Name", "name");
table.addColumn("Email", "email");
table.addColumn("Role", "role", user -> new JChip(user.getRole()));
table.setRowActions((user, box) -> {
    JButton editBtn = new JButton("Edit");
    editBtn.setOnAction(e -> editUser(user));
    box.getChildren().add(editBtn);
});
table.setItems(userData);

Column Configuration

addColumn(title, property)
TableColumn<T, V>
Adds a sortable column with the specified title and property name.
addColumn(title, property, sortable)
TableColumn<T, V>
Adds a column with control over sortability.
addColumn(title, property, renderer)
TableColumn<T, V>
Adds a column with a custom cell renderer.
addColumn(title, property, sortable, renderer)
TableColumn<T, V>
Adds a column with custom renderer and sortability control.

Checkable Mode

setCheckable(boolean)
void
Enables or disables checkbox selection mode. When enabled, adds a checkbox column with header “select all” control.
isCheckable()
boolean
Returns whether checkbox mode is enabled.
getCheckedItems()
ObservableList<T>
Returns the list of currently checked items.
getCheckedIndices()
List<Integer>
Returns the indices of checked items in the original data list.
clearChecks()
void
Clears all checkbox selections and resets header checkbox state.
setOnCheckChange(callback)
void
Sets a callback that fires when the checked items selection changes.

Search and Filter

setSearchable(boolean)
void
Enables or disables the search bar. Automatically filters across all column properties.
isSearchable()
boolean
Returns whether search mode is enabled.
setSearchPlaceholder(placeholder)
void
Sets the placeholder text for the search field (default: “Buscar…”).

Row Actions

setRowActions(actionsFactory)
void
Sets a factory function to create action buttons/controls for each row.
table.setRowActions((user, box) -> {
    JButton editBtn = new JButton("Edit");
    JButton deleteBtn = new JButton("Delete");
    editBtn.setOnAction(e -> editUser(user));
    deleteBtn.setOnAction(e -> deleteUser(user));
    box.getChildren().addAll(editBtn, deleteBtn);
});

Row Click

setOnRowClick(handler)
void
Sets a callback that fires when a table row is clicked.

Bulk Actions

setBulkActionsEnabled(boolean)
void
Enables or disables the bulk actions toolbar (requires checkable mode).
setOnBulkDelete(handler)
void
Sets a callback for bulk delete action and automatically enables bulk actions.

Data Management

setItems(items)
void
Sets the table’s data source.
getItems()
ObservableList<T>
Returns the current items list.
setItemsPerPage(items)
void
Sets the number of items per page for pagination (default: 10).
addItem(item)
void
Adds a single item to the table.
removeItem(item)
void
Removes a single item from the table and checked items list.
removeItems(items)
void
Removes multiple items from the table and checked items list.
refresh()
void
Refreshes the table display, reapplying filters and updating the view.

Empty State

setEmptyText(text)
void
Sets the text displayed when the table has no data.
setEmptyGraphic(graphic)
void
Sets a custom graphic/icon for the empty state.

Visual Modes

setStriped(boolean)
void
Enables or disables striped row styling (alternating row colors).
isStriped()
boolean
Returns whether striped mode is enabled.
setDense(boolean)
void
Enables or disables dense mode (compact row spacing).
isDense()
boolean
Returns whether dense mode is enabled.

Status Bar

setStatusBarEnabled(boolean)
void
Enables or disables the status bar showing “Showing X to Y of Z results”.

Pagination

setPaginationVisible(boolean)
void
Shows or hides the pagination controls.
getPagination()
JPagination
Returns the underlying JPagination component for advanced control.

Infinite Scroll

setOnScrollBottom(action)
void
Sets a callback that fires when the user scrolls to the bottom of the table.

CSV Export

exportToCSV(file)
void
Exports all table data to a CSV file.
File csvFile = new File("users.csv");
table.exportToCSV(csvFile);

Access to Underlying Components

getTableView()
TableView<T>
Returns the underlying JavaFX TableView for advanced customization.

Build docs developers (and LLMs) love