I am doing project on java.
In one of the class, I am working on jtable. Now what i am doing is,- In开发者_JAVA技巧 the table data will be loaded from the database.
Now i want to change some value at some exact row and column.
so for that i am using jtable's setValue function. which is like this....
grayCardTbl.setValueAt(Float.valueOf(String.valueOf(pdiff)),1,4);
I have checked the "pdiff" variable, it is perfect.
i had total 5 columns and 10 rows. So now problem with rowindex and column index.
and after this i have also refresh the table. but still it is not reflecting on table.
The JTable.setValueAt(...)
method calls TableModel.setValueAt(...)
.
My guess is that you've not implemented it in the model and the data doesn't get updated.
Edit: if your model calls JTable.setValueAt(...)
, it's going to loop into a stackoverflow. What you need to do is actually update the underlying data.
For instance if your model's getValueAt(...)
does return data[row][column]
, then setValueAt(...)
needs to do data[row][column] = value;
精彩评论