开发者

Why setValue at not working on Jtable?

开发者 https://www.devze.com 2022-12-30 04:58 出处:网络
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.

I am doing project on java.

In one of the class, I am working on jtable.

Now what i am doing is,

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;

0

精彩评论

暂无评论...
验证码 换一张
取 消