//Tell if this needs more info
I want to add the integers inside a cell in a column. Here's my code:
// it's in a mouse listener, eveything works fine, but what I want to do is to add
// the values (for ex. 300,400,500) 
    public void mouseClicked(MouseEvent e) {
    if(e.getClickCount() == 2) {
        JTable tbl = (JTable)e.getSource();
        int selectedRow = tbl.getSelectedRow();
        int tbl1_col = 0; // table 1's column to get the data from
        int tbl2_col = 0; // table 2's column to put the data to
   ((DefaultTableModel)tbl2.getModel()).addRow(new Object[] {null,null,null,null}); 
   //to automatically add a new row
    while(tbl1_col<tbl1.getColumnCount()) {
            tbl2.setValueAt(tbl1.getValueAt(selectedRow,tbl1_col),tbl2_row,tbl2_col);
            // Setting the value to be put on to table 2 from table 1
            System.out.println(tbl2.getValueAt(tbl2_row,3));
            tbl1_col++;
            tbl2_col++;
                if(rcol==tbl1.getColumnCount()){
                            tbl2_row++;
                }
                label.setText(String.valueOf(totalAmount));
     }
}
There's a System.out.println over there to see what values are inside and the outputs were:
null null null 300
My code to add the values:
totalAmount = totalAmount + (int) tbl2.getValueAt(tbl2_row,3));
The error I get:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
 
    