how to add a cell that contains sum of a column in jTable ?

how to add a cell that contains sum of a column in jTable ?
[73 byte] By [ariwicak] at [2007-9-26 2:17:59]
# 1
Hi,For that cell create a renderer that get the data to be sum up and prints it.JRG
j-rg at 2007-6-29 9:18:23 > top of Java-index,Archived Forums,Swing...
# 2
I have the same problem.Lets say I have 1000 rows in my table, but only 20 are visible at a time.How to make the last row of a JTable, (the one that contains the sum a column) to be always visible at the bottom of the Table?
bobi1978 at 2007-6-29 9:18:23 > top of Java-index,Archived Forums,Swing...
# 3

A simple way to add a summation row would be to have your table model simply expose the totals as a new row of data.

To make it remain visible would be a completely different matter, though.

I would do this by adding a separate table to another scrollpane (with no scrollbars) beneath the scrollpane containing your table. The horizontal offset could be linked between the two using a changeListener. You'd also have to listen to changes in the table column model to maintain column widths between the two tables.

This table could get its data from another table model that reacted to changes in the first table model.

Doing this generically is definitely possible and would give you a reusable summation row component.

Hope this helps.

KPSeal at 2007-6-29 9:18:23 > top of Java-index,Archived Forums,Swing...
# 4

A simple way to add a summation row would be to have your table model simply expose the totals as a new row of data.

To make it remain visible would be a completely different matter, though.

I would do this by adding a separate table to another scrollpane (with no scrollbars) beneath the scrollpane containing your table. The horizontal offset could be linked between the two using a changeListener. You'd also have to listen to changes in the table column model to maintain column widths between the two tables.

This table could get its data from another table model that reacted to changes in the first table model.

Doing this generically is definitely possible and would give you a reusable summation row component.

Hope this helps.onent.

Hope this helps.

electra2002 at 2007-6-29 9:18:23 > top of Java-index,Archived Forums,Swing...