Usman Ahmed
Usman Ahmed

Reputation: 79

JTable, summing up the column/rows cells values

Hello: I am using Jtable with JScrollpane and Jpanel. The table is set to DefaultTableModel and Columns are added with addColumn("Column Name); method. Rows are added with addRow(Vector); method. Now I want to sum up all the column values and display the summed result to a particular JTextField. I searched a lot for the answer but unable to got the reliable answer.

Upvotes: 1

Views: 700

Answers (1)

rahool
rahool

Reputation: 639

DefaultTableModel have a method getValueAt(int row, int column); You can iterate over the columns and compute the total using value from getValueAt method.

Upvotes: 2

Related Questions