hi everyone

is there anyway to get all cell values of a column in the jtable?

for instance i have to get all the values in column1 which are all integers and sum it up to the textbox.

:) thanks!

Edited 4 Years Ago by JamesCherrill: Old thread

JTable's getValueAt(int row, int column) method returns the value in any cell, so you can loop thru any col you like getting the values and adding them up.

yes, i know the getValueAt(int row,int col) method...but my issue here is that i do have a hundred records in column1 in the jtable.

how can i get the hundred records and sum it up in one textbox..how should i loop it..

:) thanks so much!

im still a newbie in java...still learning the language...:icon_redface:

thanks again!:icon_lol:

Here's the kind of loop you need. (I've left the detailed syntax for you to work out for yourself)

int total = 0;
for (int i = i; i < (number of rows in the table); i++ ) {
   total = total + value in cell(i, columnNumber);
}
display total in textBox;

hey everyone,
i need help in getting the sum of all values in column of a jtable and diplay it in a textfeild.it should also change when an item is edited
:) thanks