Java Reference
In-Depth Information
public Object getValueAt(int row, int column) {
checkModel();
return model.getValueAt(indexes[row], column);
}
public void setValueAt(Object aValue, int row, int column) {
checkModel();
model.setValueAt(aValue, indexes[row], column);
}
public void sortByColumn(int column) {
sortByColumn(column, true);
}
public void sortByColumn(int column, boolean ascending) {
this.ascending = ascending;
sortingColumns.removeAllElements();
sortingColumns.addElement(new Integer(column));
sort();
super.tableChanged(new TableModelEvent(this));
}
}
Note The TableSorter borrows heavily from the TableExample that comes with the JFC/Swing release.
The TableMap class, shown in Listing 18-7, serves as a proxy, passing along all calls to the
appropriate TableModel class. It's the superclass of the TableSorter class shown in Listing 18-6.
Listing 18-7. Table Sorting Support Map
import javax.swing.table.*;
import javax.swing.event.*;
public class TableMap extends AbstractTableModel implements TableModelListener {
TableModel model;
public TableModel getModel() {
return model;
}
 
Search WWH ::




Custom Search