< prev index next >

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

Print this page

    @@ -453,10 +453,11 @@
             changeSelection(clearMin, clearMax, setMin, setMax, true);
         }

         /** {@inheritDoc} */
         public void clearSelection() {
    +        updateLeadAnchorIndices(-1, -1);
             removeSelectionIntervalImpl(minIndex, maxIndex, false);
         }

         /**
          * Changes the selection to be between {@code index0} and {@code index1}

    @@ -689,22 +690,18 @@
             for(int i = rmMinIndex; i <= maxIndex; i++) {
                 setState(i, value.get(i + gapLength));
             }

             int leadIndex = this.leadIndex;
    -        if (leadIndex == 0 && rmMinIndex == 0) {
    -            // do nothing
    -        } else if (leadIndex > rmMaxIndex) {
    +        if (leadIndex > rmMaxIndex) {
                 leadIndex = this.leadIndex - gapLength;
             } else if (leadIndex >= rmMinIndex) {
                 leadIndex = rmMinIndex - 1;
             }

             int anchorIndex = this.anchorIndex;
    -        if (anchorIndex == 0 && rmMinIndex == 0) {
    -            // do nothing
    -        } else if (anchorIndex > rmMaxIndex) {
    +        if (anchorIndex > rmMaxIndex) {
                 anchorIndex = this.anchorIndex - gapLength;
             } else if (anchorIndex >= rmMinIndex) {
                 anchorIndex = rmMinIndex - 1;
             }

< prev index next >