Search code examples
javaswingjtabletablemodel

Jtable - getvalueAt() issue


I want to know why my getvalueAt() is picking old data when Enter is pressed.
I tried all update and table change modules, but I couldn't get it working. I am making an Excel sheet-like structure in JTable, in which one row updates on change to another row.

public void setValueAt(Object aValue, int row, int column) {
        if(column == 2 || column == 3 || column == 4 || column == 5)
    {
        System.out.println("2 is: "+getValueAt(row, 2));
        System.out.println("3 is: "+getValueAt(row, 3));
        System.out.println("4 is: "+getValueAt(row, 4));
        long closingbalance = Long.parseLong(getValueAt(row,2).toString())
            + Long.parseLong(getValueAt(row,3).toString())
            - Long.parseLong(getValueAt(row,4).toString());
        System.out.println("closing: "+closingbalance);
        super.setValueAt(closingbalance,row, 6);
    }               
    super.setValueAt(aValue, row, column);
}

Solution

  • I can't be able to answering your question on another forum, because a new forums version driving me crazy

    • there no reason parsing value from JTable,

    • JTable implemets all important data types

    • examples here or here

    • for better help edit your question with SSCCE