posted 23 years ago
Here is the scenario: I have a dialog that contains 2 JTables. Each table is alike (same number of rows and columns, instances of the same tableModel...). My application gets updated data 4 times per second: whenever an update occurs a method in my class is called to get the updates and write them to the table cells. I am using the setValueAt() method of the tableModel to change the cells in the table. Although the tables contain data of the same type, when my application is running the LEFT table should be getting data displayed in the lower half of the table and the RIGHT table should be getting data displayed in the upper half of the table.
The problem is that at run-time when the tables are being updated the RIGHT table (the table that gets updated last) displays properly, but the LEFT table does not. The LEFT table switches back and forth at a random rate between what it is supposed to show and what the RIGHT table shows. It is almost as if the LEFT tableModel is getting it's reference mixed up. If I put breaks in my code and step through it, the cells that are supposedly getting updated are correct. I have added printlns to the code to see what is happening and to my surprise the calls to System.out.println actually appear to help correct the problem. I should not need to add delays to my code to get this to work correctly, but that is what it is appearing I might have to do.
If I remove the RIGHT table from the dialog the LEFT table displays fine...
Any clues as to why one table is getting random repaints of data that is from another table?
Clueless...
Lon Allen