I would like to enlighten my knowledge of Table Model. In this program, the RightTable(RightModel) is updated as soon as the left table changes.
To do it, the solution I found is based on a TableModelListener and a TableModel where fireTableCellUpdated is used in the setValueAt method.
I think I was explained in this forum this is the wrong way...
The right way should be to used the setValueAt method of the TableModel. I tried it without success. So any idea on how to update the RightTable the right way?
Thank you for your help.
Done! I just add "fireTableCellUpdated(rowIn, col);" at the beginning of the getValueAt method in the RightModel Class.
But it is updated before the real thing is done... Strange enough it seems to work!
Not sure this would be the recommended way. Anyone?
To sum up:
In this code I have 2 tables from class MyTable and RightTable.
The first table is externally updated every second. The rows of the second table should be updated when the rows of the first table are updated.
What I first did was: addTableModelListener to the TableModel of the first table and use e.getType() == TableModelEvent.UPDATE
To avoid using the addTableModelListener method, the solution I propose is to update the second table in the update(Observable,Object) method of the model of MyTable.
It works fine and I think this is the best solution so far. Or do you have any other ideas?