1

I'm trying to display a total integer value taken from the Jtable cells and want to display the sum in the last cell so for that i need to covert the final sum to object or are there any other solution...any help will be thankful!!!

Votes + Comments
good question
3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by mKorbel
0

This depends on the TableModel you are using. What is your table model?

Its Default

0

Good, that's easy. Any kind of Object will work. You can either convert to an Integer object, which preserves the numeric quality if you plan any further calcs, or convert to a String object, which displays with the minimum overhead.

new Integer(sum);
String.valueOf(sum)
0

that's very good idea, but would be impossible in case that JTable has used RowSorter or RowFilter

1/ if isn't there implemented and used RowSorter or RowFilter, add TableModelListener,

2/ move TableHeader (then you lost) from Top to the JTable's bottom and if isn't there implemented and used RowSorter or RowFilter, add TableModelListener,

add(table, BorderLayout.CENTER);
add(header, BorderLayout.SOUTH);

3/ if is there implemented and used RowSorter or RowFilter dirty hack

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.