SwingLabs: How to Use the SwingX JXTable


A JXTable is an extension to the standard Swing JTable adding support for runtime column selection, column rearrangement, background row highlighting, sorting and other features. A JXTable can be used just like a JTable, while allowing you to offer your users an extended feature set with no extra coding.
The extended features of JXTable are:
Feature What it does
Column Control The JXTable introduces a small column control button, which opens a popup menu to configure the JXTable's display and behavior. The column control appears discretely to the right of the column headers.
Selecting Columns Users can select the columns they want to see on the JXTable by selecting the columns from the column control's popup menu.
Rearranging Columns Users can change columns on screen by dragging and dropping the columns to their new position.
Highlighting Rows You can highlight rows in a JXTable by attaching a Highlighter. Highlighting allows you to easily distinguish between different rows, for example, every other row, using a subtle background color scheme.
Sorting Rows JXTable has built-in support for row sorting at runtime, allowing the user to click on a column header and sort by that column. Using custom Comparators, you can determine the sorting rules that apply to different columns.
Filtering Rows You can attach one or more filters to a JXTable, allowing you to control which rows are shown to the user.
Resizing Columns Users can auto-resize columns to fit their contents from the column control.

Contents of this How-To



Working with a JXTable


This section covers how to use a JXTable in your code. We start with an overview of using a JXTable, then continue by describing each major feature of JXTable in turn.

Getting Started with a JXTable


TODO: JXTable is a JTable, so you still need to code a TableModel to use it, and wrap it in a JScrollPane if there's enough data to scroll on.

The JXTable Column Control


TODO:

Selecting Columns at Runtime


TODO:

Rearranging Columns via Drag and Drop


TODO:

Highlighting Rows


TODO:

Sorting Rows


TODO:

Filtering Rows from Display


TODO:

Resizing Columns


TODO:

Links to Demos and Related Documents


TODO: swingX demo, other demos? TODO: related classes: JXTreeTable, JXScrollPane, Filter, Highlighter