Skip to content

JDK 6 以前のJTable

Sort JTables with TableSorter

TableSorter

This example uses TableSorter.java, which was available in TheJava™ Tutorial prior to JDK 1.5.0, to sort rows in a JTable in descending, ascending, and initial state.

The selection state is maintained even when sorting with TableSorter.

Section titled “The selection state is maintained even when sorting with TableSorter.”
The selection state is maintained even when sorting with TableSorter.

SelectionKeeper

Even when sorting using TableSorter.java, the row selection state is saved.

JTable sorting

SortableTable

Clicking on the column headers in the JTable sorts the rows in descending or ascending order.

Make the JTableHeader column unselectable.

Section titled “Make the JTableHeader column unselectable.”
Make the JTableHeader column unselectable.

DisabledHeader

This disables the selection of columns in the JTableHeader, preventing sorting and other operations.

Switching the display of rows in a JTable using row filters.

Section titled “Switching the display of rows in a JTable using row filters.”
Switching the display of rows in a JTable using row filters.

FilteredTable

Use filters to select which rows to display in the JTable.

Move rows in a JTable

MoveRow

Use the toolbar or pop-up menu to move rows in the JTable up or down.