<Swing Dev> [11] Review Request: JDK-4334792: Lead Index in DefaultListSelectionModel will never return to -1

Semyon Sadetsky semyon.sadetsky at oracle.com
Fri Feb 16 16:24:35 UTC 2018


My point is the same as in 6481195 your fix always changes lead/anchor=0 
to -1 even when elements exist.

I'm not so sure about clearSelection(). In JDK usages of this method we 
set lead/anchor to -1 explicitly when this really needed. Although I 
don't see enough reason to make this implicit now, anyway, why you 
didn't delete those explicit -1s?

--Semyon


On 02/16/2018 08:08 AM, Pankaj Bansal wrote:
>
> Hi Semyon,
>
> 1.This fix has an additional change involved when JList.clearSelection 
> is called. So this is not duplicate bug.
>
> 2.I think you only mentioned that the 6481195 does not talk about 
> lead/achor and we should not change these values in that bug and 
> create a new bug for those changes. I used this bug instead of 
> creating a new bug.
>
> I can’t close this bug as duplicate as this involve additional 
> changes. I can close 6481195 as “fixed in someother bug” as it is 
> subset of the present issue.
>
> Regards,
>
> Pankaj Bansal
>
> *From:*Semyon Sadetsky
> *Sent:* Friday, February 16, 2018 8:59 PM
> *To:* Pankaj Bansal; swing-dev at openjdk.java.net
> *Subject:* Re: <Swing Dev> [11] Review Request: JDK-4334792: Lead 
> Index in DefaultListSelectionModel will never return to -1
>
> You've already sent this change in 6481195 review. Please continue in 
> 6481195  tread. The current bug  should be closed as duplicate.
>
> On 02/15/2018 09:36 PM, Pankaj Bansal wrote:
>
>     Hi All,
>
>     Please review the fix for JDK 11.
>
>     Bug:
>
>     https://bugs.openjdk.java.net/browse/JDK-4334792
>
>     webrev:
>
>     http://cr.openjdk.java.net/~pbansal/4334792/webrev.00/
>     <http://cr.openjdk.java.net/%7Epbansal/4334792/webrev.00/>
>
>     Issue:
>
>     Lead Index in DefaultListSelectionModel will never return to -1 in
>     some cases as described.
>
>     Fix:
>
>     1) JList.setSelectionIndex(-1)
>
>     The doc says JList.setSelectedIndex() should select a single cell,
>     but it doesn't mean it should clear selection if the argument is -1.
>
>     This will also not be fixed as this is not an issue and behavior
>     is expected.
>
>     2) JList.clearSelection()
>
>     The proposed fix addresses this issue.
>
>     3) ListModel.removeAllElements()/ListModel.clear
>
>     This issue has been addressed already except the case when the
>     lead/anchor is 0/0 and then
>     JList.removeAllElements/ListModel.clear is called, then the
>     anchor/lead is not set properly. This case is addressed in the
>     proposed fix. This will also fix the
>     https://bugs.openjdk.java.net/browse/JDK-6481195
>
>     4) ListSelectionModel.setLeadSelectionIndex()
>
>     This is not an issue as lead can be set to -1 by
>     setLeadSelectionIndex, if the anchor is already set properly. This
>     is expected behavior and will not be changed.
>
>     Regards,
>
>     Pankaj Bansal
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20180216/01e46c3e/attachment.html>


More information about the swing-dev mailing list