Posted Thursday, November 27, 2008 @ 08:31:56
//after loading the data
dbtable.refresh();
//add the summary row
int totalRow = dbtable.getRowCount(); //if users add any rows,this row variable should be reset
dbtable.insertSilent(java.util.Vector insertElements, totalRow) ;
//initialize the summary row data
for(int i=1; i<=dbTable.getColumnCount() ; i++ )
{
Object newTotal = calculateTotalForColumn(i);
dbTable.setValueAt(newTotal, totalRow, i);
}
//listen for change in data and update summary row
class MyCellListener implements DBTableCellListener
{
public Object cellValueChanged(int row, int col, Object oldValue, Object newValue)
{
Object newTotal = calculateTotalForColumn(col);
dbTable.setValueAt(newTotal, totalRow, col );
return newvalue;
}
}
dbTable.addTableCellListener(new MyCellListener());
if you want to just change the foreground/background color/font/editable of the total row, then use CellPropertiesModel, refer api http://quicktable.org/doc/quick/dbtable/CellPropertiesModel.html