0

When you update the data in a TableModel you're supposed to notify the listeners by calling one of the "table data changed" methods, either fireTableDataChanged or one of the more specific methods.

Is there an advantage to calling one of the more specific methods versus the catch-all? The documentation for fireTableDataChanged says it causes the table to redraw itself from scratch. Even on a table with a lot of elements, this shouldn't cause a performance penalty as only the elements on-screen get redrawn, right?

ntm
  • 83
  • 1
  • 6
  • 1
    `JTable` itself may optimize rendering, but other listeners may not; [profile](http://stackoverflow.com/q/2064427/230513) to be sure. – trashgod Jun 09 '17 at 00:02
  • 1
    `fireTableDataChanged` cause it the `JTable` to revalidate the `ColumnModel`, `TableRowSorter` and update ALL the row information, which also invalidates the table row/column selection. The more specific events allow the `JTable` to make "micro" changes (so removing/adding a row won't affect the `ColumnModel` and may not affect the current selection), they also reduce the amount of updating the table needs to in terms of what it needs to paint – MadProgrammer Jun 09 '17 at 00:19

0 Answers0