public class TableSorter extends Object
Example of use:
TableModel model = ... DefaultSortableTableModel sm = new DefaultSortableTableModel(model); JTable table = new JTable(sm); TableSorter sorter = new TableSorter(table);
SortableTableModel
Modifier and Type | Class and Description |
---|---|
private class |
TableSorter.HeaderListener |
private class |
TableSorter.HeaderRenderer |
private class |
TableSorter.ModelChangeListener |
private static class |
TableSorter.Triangle |
Modifier and Type | Field and Description |
---|---|
private static Icon |
downTriangle |
private JTableHeader |
header |
private SortableTableModel |
model |
private static Icon |
upTriangle |
Constructor and Description |
---|
TableSorter(JTable table)
Create a TableSorter.
|
TableSorter(JTable table,
int column)
Create a TableSorter.
|
TableSorter(JTable table,
int column,
boolean ascending)
Create a TableSorter specifiying initial sorting parameters.
|
Modifier and Type | Method and Description |
---|---|
int |
getSortOnColumn()
Find the current sort column.
|
boolean |
isSortAscending()
Get the current sort order.
|
private void |
modelChanged(TableModel model) |
void |
setSortAscending(boolean ascending)
Set the current sort order.
|
void |
setSortOnColumn(int column)
Set the sort column.
|
private void |
sort(int sortOnColumn,
boolean sortAscending) |
private static Icon downTriangle
private static Icon upTriangle
private SortableTableModel model
private JTableHeader header
public TableSorter(JTable table)
table
- The table to be sortedpublic TableSorter(JTable table, int column)
table
- The table to be sorted.column
- The column on which to sort, or SortableTableModel.UNSORTED
public TableSorter(JTable table, int column, boolean ascending)
table
- The table to be sorted.column
- The column on which to sort, or SortableTableModel.UNSORTED
ascending
- true
for ascending order, false
for descending orderpublic int getSortOnColumn()
SortableTableModel.UNSORTED
public void setSortOnColumn(int column)
column
- The column on which to sort, or SortableTableModel.UNSORTED
public boolean isSortAscending()
true
if ascending order, false
for descending order.public void setSortAscending(boolean ascending)
ascending
- true
for ascending order, false
for descending orderprivate void sort(int sortOnColumn, boolean sortAscending)
private void modelChanged(TableModel model)
Copyright © 2016 Linear Collider Detector (LCD). All rights reserved.