FreeHEP API
Version current

org.freehep.swing.table
Class DefaultSortableTableModel

java.lang.Object
  extended byorg.freehep.swing.table.DefaultSortableTableModel
All Implemented Interfaces:
SortableTableModel, TableModel

public class DefaultSortableTableModel
extends Object
implements SortableTableModel

Converts any TableModel to a SortableTableModel.

Version:
$Id: DefaultSortableTableModel.java,v 1.6 2004/07/26 18:07:37 tonyj Exp $
Author:
Tony Johnson
Source Code:
DefaultSortableTableModel.java

Field Summary
 
Fields inherited from interface org.freehep.swing.table.SortableTableModel
UNSORTED
 
Constructor Summary
DefaultSortableTableModel(TableModel source)
          Creates a new instance of DefaultTableSorter
 
Method Summary
 void addTableModelListener(TableModelListener l)
           
protected  void fireTableChanged(TableModelEvent event)
          Notifies all listeners of a change to the sorted TableModel.
 Class getColumnClass(int columnIndex)
           
 int getColumnCount()
           
 String getColumnName(int columnIndex)
           
 int getRowCount()
           
 Object getValueAt(int rowIndex, int columnIndex)
           
 boolean isCellEditable(int rowIndex, int columnIndex)
           
 void removeTableModelListener(TableModelListener l)
           
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
           
 void sort(int column, boolean ascending)
          Sort the table model using the given column.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSortableTableModel

public DefaultSortableTableModel(TableModel source)
Creates a new instance of DefaultTableSorter

Parameters:
source - The table model to be converted.
Method Detail

addTableModelListener

public void addTableModelListener(TableModelListener l)
Specified by:
addTableModelListener in interface TableModel

getColumnClass

public Class getColumnClass(int columnIndex)
Specified by:
getColumnClass in interface TableModel

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface TableModel

getColumnName

public String getColumnName(int columnIndex)
Specified by:
getColumnName in interface TableModel

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface TableModel

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)
Specified by:
getValueAt in interface TableModel

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Specified by:
isCellEditable in interface TableModel

removeTableModelListener

public void removeTableModelListener(TableModelListener l)
Specified by:
removeTableModelListener in interface TableModel

setValueAt

public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex)
Specified by:
setValueAt in interface TableModel

sort

public void sort(int column,
                 boolean ascending)
Description copied from interface: SortableTableModel
Sort the table model using the given column. Once this method has been called the table model should reorder its rows so that they are sorted using the given column. The table model should generate appropriate change events to reflect any changes made to the model as a result of the sort. If the table data is modified after sort has been called, the table model should continue to sort the data using the given column.

Specified by:
sort in interface SortableTableModel
Parameters:
column - The index of the column to sort on, or UNSORTED if no sort is necessary.
ascending - If true sort in ascending order, else sort in descending order.

fireTableChanged

protected void fireTableChanged(TableModelEvent event)
Notifies all listeners of a change to the sorted TableModel.

Parameters:
event - The event to be sent to the listeners.

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.