0

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

mKorbel
  • 109,525
  • 20
  • 134
  • 319
user2436012
  • 31
  • 1
  • 2
  • 6

2 Answers2

3

to get cell value you can to do something like that

table.getModel().getValueAt(rowIndex, columnIndex)
Sergii Zagriichuk
  • 5,389
  • 5
  • 28
  • 45
  • Yes, because there are two layers top is table(model) low is text editor(cell), the value is present on lovest layer and you can reach it using TableCellEditor (as described above), after "flushing" data, value will be present in table model (top layer) and can be reached by my exaple. – Sergii Zagriichuk Aug 16 '13 at 11:02
3

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.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045