Convert integer to object
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!!!
47pirates
Junior Poster in Training
88 posts since Dec 2009
Reputation Points: 19
Solved Threads: 1
This depends on the TableModel you are using. What is your table model?
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
This depends on the TableModel you are using. What is your table model?
Its Default
47pirates
Junior Poster in Training
88 posts since Dec 2009
Reputation Points: 19
Solved Threads: 1
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)
JamesCherrill
Posting Genius
6,373 posts since Apr 2008
Reputation Points: 2,130
Solved Threads: 1,073
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
mKorbel
Veteran Poster
1,141 posts since Feb 2011
Reputation Points: 480
Solved Threads: 224