简体   繁体   English

获取jtable的单元格值

[英]Get cell values of jtable

I have a jtable with column item,quantity,rate and amount.If i enter value in quantity and press tab key the total amount is getting calculated that is working fine.But i need the amount to be calculated on typing the quantity. 我有一个带有列项目,数量,比率和数量的jtable。如果我输入数量值,然后按Tab键,总数量就可以正常工作了。但是我需要在输入数量时计算数量。 I want it to be done on key pressed of numbers or on typing number.I have used default jtable using netbeans 我想通过按数字键或键入数字来完成它。我已经使用netbeans的默认jtable

要获取单元格值,您可以执行类似的操作

table.getModel().getValueAt(rowIndex, columnIndex)

In response to an answer suggesting getValueAt() , you say, "I used the above code but it prints as null ." 在回答建议getValueAt()的答案时,您说:“我使用了上面的代码,但打印为null 。” As discussed here , the value is not available in the model until the editor concludes. 作为讨论在这里 ,价值是不可用的模型,直到编辑总结。 You'll need a custom TableCellEditor that uses a DocumentListener to update your total. 您需要一个使用DocumentListener的自定义TableCellEditor来更新总数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM