< prev index next >

## src/java.desktop/share/classes/javax/swing/DefaultRowSorter.java

Print this page

    @@ -1031,12 +1031,14 @@
         private boolean shouldOptimizeChange(int firstRow, int lastRow) {
             if (!isTransformed()) {
                 // Not transformed, nothing to do.
                 return false;
             }
    -        if (!sorted || (lastRow - firstRow) > viewToModel.length / 10) {
    -            // We either weren't sorted, or to much changed, sort it all
    +        if (!sorted || viewToModel.length == 0 ||
    +                (lastRow - firstRow) > viewToModel.length / 10) {
    +            // We either weren't sorted, or to much changed, sort it all or
    +            // this is the first row added and we have to update diffeent caches
                 sort();
                 return false;
             }
             return true;
         }

< prev index next >