Skip to content

Commit

Permalink
Impl. of SwingPropertySupport.rowCountProperty(JTable table)
Browse files Browse the repository at this point in the history
  • Loading branch information
parubok committed Oct 28, 2022
1 parent 2e59248 commit 405be25
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public static IntegerProperty selectedIndexProperty(JTabbedPane tabbedPane) {
* @return Read-only property which value is the number of visible rows of the table.
* @see javax.swing.DefaultRowSorter#setRowFilter(javax.swing.RowFilter)
* @see JTable#getRowCount()
* @implNote In some cases, the property change events are fired via {@link javax.swing.SwingUtilities#invokeLater(Runnable)}.
*/
public static ReadOnlyIntegerProperty rowCountProperty(JTable table) {
return TableRowCountPropertyImpl.getProperty(table);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ private static class TableRowCountProperty extends ReadOnlyIntegerPropertyBase {
this.rowSorterListener = e -> rowCountPossiblyChanged();
this.tableModelListener = e -> {
if (e.getType() != TableModelEvent.UPDATE) {
// in Java 11, the JTable is not yet updated at this moment,
// so I need to postpone the event:
// in Java 11, the JTable's row sorter is not yet updated at this moment,
// and JTable.getRowCount() returns the old value:
SwingUtilities.invokeLater(this::rowCountPossiblyChanged);
}
};
Expand Down

0 comments on commit 405be25

Please sign in to comment.