user2436012
user2436012

Reputation: 31

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. I want it to be done on key pressed of numbers or on typing number.I have used default jtable using netbeans

Upvotes: 0

Views: 11040

Answers (2)

trashgod
trashgod

Reputation: 205785

In response to an answer suggesting getValueAt(), you say, "I used the above code but it prints as 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.

Upvotes: 3

Sergii Zagriichuk
Sergii Zagriichuk

Reputation: 5399

to get cell value you can to do something like that

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

Upvotes: 3

Related Questions