Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Please ask technical questions in the appropriate category. Thank you!

Efficient JTable updates

843806Oct 13 2008 — edited Oct 13 2008
RE: Java 1.5 Update 16

All,

I'm sure I'm not covering new ground here, but my web searches are not resulting in any useful information. I'm trying to figure out how to efficiently update a JTable when the underlying data model changes. I'm aware of the AbstractTableModel and API such as fireTableCellUpdated. However, the problem I've observed is that the JTable code seems to be redrawing a rect around all the cells that have changed during a particular EventQueue loop. So, let's say just two cells have changed 0:0 and X:Y where X = numRows and Y = numCols. Even though only two cells have been updated (i.e. I have called fireTableCellUpdated twice in succession on 0:0 and X:Y), in my testing, the entire table is redrawn, because the two cells in question are the upper left cell and the lower right cell in the table. The JTable redrawing code seems to draw one big rect around both cells and ends up updated everything in between. If I break up the calls to fireTableCellUpdated to separate passes through the EventQueue, then just the corners are updated. However, in the case of my data model and rapid firing of updates, I cannot break things up this way. Does anyone know if there's any better way to approach this? Any advice would be much appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 10 2008
Added on Oct 13 2008
4 comments
2,982 views