This is my Code below. I have created a Jtable with 4 column and 3 rows. and add table model listener, In the Table change Listener, When i set the value in a particular column
JTable#setValueAt
will call TableModel#setValueAt
, which will trigger a TableChanged
event, which is why it's causing you a StackOverflowException
(it's caught in an infinite loop)
The better solution would be to override the TableModel#setValueAt
and if the column 0
, 1
or 2
is updated, also calculate the value for column 3
, but don't forget to fire a cellUpdated
event