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!
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!
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;
got it!;)
:) thanks!
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
DaniWeb Member Rules include:
"Do not hijack old threads by posting a new question as a reply to an old one"
http://www.daniweb.com/community/rules
Please start your own new thread for your question
This thread is closed.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.