com.jrefinery.ui
Class SortableTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.jrefinery.ui.SortableTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel
Direct Known Subclasses:
SystemPropertiesTableModel

public abstract class SortableTableModel
extends javax.swing.table.AbstractTableModel

The base class for a sortable table model.

See Also:
Serialized Form

Field Summary
protected  boolean ascending
          Indicates ascending (true) or descending (false) order.
protected  int sortingColumn
          The column on which the data is sorted (-1 for no sorting).
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
SortableTableModel()
          Constructs a sortable table model.
 
Method Summary
 boolean getAscending()
          Returns true if the data is sorted in ascending order, and false otherwise.
 int getSortingColumn()
          Returns the index of the sorting column, or -1 if the data is not sorted on any column.
 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
 

Field Detail

sortingColumn

protected int sortingColumn
The column on which the data is sorted (-1 for no sorting).


ascending

protected boolean ascending
Indicates ascending (true) or descending (false) order.

Constructor Detail

SortableTableModel

public SortableTableModel()
Constructs a sortable table model.

Method Detail

getSortingColumn

public int getSortingColumn()
Returns the index of the sorting column, or -1 if the data is not sorted on any column.

Parameters:
The - column used for sorting.

getAscending

public boolean getAscending()
Returns true if the data is sorted in ascending order, and false otherwise. *

Returns:
True if the data is sorted in ascending order, and false 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).


Copyright © 2003 MBARI.

The Monterey Bay Aquarium Research Institute (MBARI) provides this documentation and code "as is", with no warranty, express or implied, of its quality or consistency. It is provided without support and without obligation on the part of MBARI to assist in its use, correction, modification, or enhancement.