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!!!

mKorbel commented: good question +9

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

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

Its Default

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)

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.