HOME

com.ultraswing
Class DefaultSortableTableModel

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--javax.swing.table.DefaultTableModel
              |
              +--com.ultraswing.DefaultSortableTableModel
All Implemented Interfaces:
Serializable, SortableTableModel, TableModel
Direct Known Subclasses:
ResultSetTableModel

public class DefaultSortableTableModel
extends DefaultTableModel
implements SortableTableModel

This is an implementation of SortableTableModel

See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.DefaultTableModel
columnIdentifiers, dataVector
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
DefaultSortableTableModel()
          Constructs a DefaultSortableTableModel
DefaultSortableTableModel(int rowCount, int columnCount)
          Constructs a DefaultSortableTableModel with rowCount and columnCount of null object values.
DefaultSortableTableModel(Object[][] data, Object[] columnNames)
          Constructs a DefaultSortableTableModel and initializes the table by passing data and columnNames to the setDataVector method.
DefaultSortableTableModel(Object[] columnNames, int numRows)
          Constructs a DefaultSortableTableModel with as many columns as there are elements in columnNames and numRows of null object values.
DefaultSortableTableModel(Vector columnNames, int numRows)
          Constructs a DefaultSortableTableModel with as many columns as there are elements in columnNames and numRows of null object values.
DefaultSortableTableModel(Vector data, Vector columnNames)
          Constructs a DefaultSortableTableModel and initializes the table by passing data and columnNames to the setDataVector method.
 
Method Summary
 int getSortedColumnIndex()
          Returns the sorted column, or -1 if no column is sorted
 boolean isAscending()
          Returns true if it's ascending order
 boolean isSortable(int col)
          Returns true if this table model is sortable
 void setSortByColumn(int column, boolean ascending)
          Sets the sorting order of colum
 
Methods inherited from class javax.swing.table.DefaultTableModel
addColumn, addColumn, addColumn, addRow, addRow, convertToVector, convertToVector, getColumnCount, getColumnName, getDataVector, getRowCount, getValueAt, insertRow, insertRow, isCellEditable, moveRow, newDataAvailable, newRowsAdded, removeRow, rowsRemoved, setColumnCount, setColumnIdentifiers, setColumnIdentifiers, setDataVector, setDataVector, setNumRows, setRowCount, setValueAt
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, removeTableModelListener
 
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
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, getValueAt, isCellEditable, removeTableModelListener, setValueAt
 

Constructor Detail

DefaultSortableTableModel

public DefaultSortableTableModel()
Constructs a DefaultSortableTableModel


DefaultSortableTableModel

public DefaultSortableTableModel(int rowCount,
                                 int columnCount)
Constructs a DefaultSortableTableModel with rowCount and columnCount of null object values.


DefaultSortableTableModel

public DefaultSortableTableModel(Object[][] data,
                                 Object[] columnNames)
Constructs a DefaultSortableTableModel and initializes the table by passing data and columnNames to the setDataVector method. The first index in the Object[][] array is the row index and the second is the column index.

Parameters:
data - the data of the table
columnNames - the names of the columns

DefaultSortableTableModel

public DefaultSortableTableModel(Object[] columnNames,
                                 int numRows)
Constructs a DefaultSortableTableModel with as many columns as there are elements in columnNames and numRows of null object values. Each column's name will be taken from the columnNames array.

Parameters:
columnNames - array containing the names of the new columns. If this is null then the model has no columns
numRows - the number of rows the table holds

DefaultSortableTableModel

public DefaultSortableTableModel(Vector columnNames,
                                 int numRows)
Constructs a DefaultSortableTableModel with as many columns as there are elements in columnNames and numRows of null object values. Each column's name will be taken from the columnNames vector.

Parameters:
columnNames - vector containing the names of the new columns. If this is null then the model has no columns
numRows - the number of rows the table holds
See Also:
DefaultTableModel.setDataVector(java.util.Vector, java.util.Vector), DefaultTableModel.setValueAt(java.lang.Object, int, int)

DefaultSortableTableModel

public DefaultSortableTableModel(Vector data,
                                 Vector columnNames)
Constructs a DefaultSortableTableModel and initializes the table by passing data and columnNames to the setDataVector method.

Parameters:
data - the data of the table
columnNames - vector containing the names of the new columns
Method Detail

isSortable

public boolean isSortable(int col)
Returns true if this table model is sortable

Specified by:
isSortable in interface SortableTableModel

setSortByColumn

public void setSortByColumn(int column,
                            boolean ascending)
Sets the sorting order of colum

Specified by:
setSortByColumn in interface SortableTableModel
Parameters:
column - colum index
ascending - if true, sort the specified column into ascending order

isAscending

public boolean isAscending()
Returns true if it's ascending order

Specified by:
isAscending in interface SortableTableModel

getSortedColumnIndex

public int getSortedColumnIndex()
Returns the sorted column, or -1 if no column is sorted

Specified by:
getSortedColumnIndex in interface SortableTableModel

HOME

Copyright © 2002 iReasoning Networks. All Rights Reserved.