Package org.jfree.ui
Class SortableTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- org.jfree.ui.SortableTableModel
-
- All Implemented Interfaces:
Serializable
,TableModel
- Direct Known Subclasses:
SystemPropertiesTableModel
public abstract class SortableTableModel extends AbstractTableModel
The base class for a sortable table model.- Author:
- David Gilbert
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
-
Constructor Summary
Constructors Constructor Description SortableTableModel()
Constructs a sortable table model.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getSortingColumn()
Returns the index of the sorting column, or -1 if the data is not sorted on any column.boolean
isAscending()
Returnstrue
if the data is sorted in ascending order, andfalse
otherwise.boolean
isSortable(int column)
Returns a flag indicating whether or not a column is sortable.void
setAscending(boolean flag)
Sets the flag that determines whether the sort order is ascending or descending.void
sortByColumn(int column, boolean ascending)
Sorts the table.-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.swing.table.TableModel
getColumnCount, getRowCount, getValueAt
-
-
-
-
Method Detail
-
getSortingColumn
public int getSortingColumn()
Returns the index of the sorting column, or -1 if the data is not sorted on any column.- Returns:
- the column used for sorting.
-
isAscending
public boolean isAscending()
Returnstrue
if the data is sorted in ascending order, andfalse
otherwise.- Returns:
true
if the data is sorted in ascending order, andfalse
otherwise.
-
setAscending
public void setAscending(boolean flag)
Sets the flag that determines whether the sort order is ascending or descending.- Parameters:
flag
- the flag.
-
sortByColumn
public void sortByColumn(int column, boolean ascending)
Sorts the table.- Parameters:
column
- the column to sort on (zero-based index).ascending
- a flag to indicate ascending order or descending order.
-
isSortable
public boolean isSortable(int column)
Returns a flag indicating whether or not a column is sortable.- Parameters:
column
- the column (zero-based index).- Returns:
- boolean.
-
-