madhawaseeeee

jtable example

Jun 26th, 2015
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1.  while(rs.next()){
  2.      Vector<String> rowData = new Vector<>();
  3.       rowData.add(rs.getString(1));
  4.       rowData.add(rs.getString(2));
  5.       rowData.add(rs.getString(3));
  6.  
  7.       model.addRow(rowData);
  8.  }
  9. //after the loop count the sum of 3rd column
  10.  
  11. int total=0;
  12. for (int i = 0; i < model.getRowCount(); i++){
  13.     total +=Integer.parseInt( model.getValueAt(i, 2).toString() );// 3rd column . row column indexes are 0 based
  14. }
  15.  
  16. System.out.println("sum of 3rd line is "+total);
Advertisement
Add Comment
Please, Sign In to add comment