<Swing Dev> [11] Review Request: JDK-6481195 ListSelectionListener indicates events on model.addElement after model.clear()
Pankaj Bansal
pankaj.b.bansal at oracle.com
Mon Jan 22 13:12:40 UTC 2018
Hi All,
Please review the fix for JDK 11.
Bug:
https://bugs.openjdk.java.net/browse/JDK-6481195
Webrev:
http://cr.openjdk.java.net/~pbansal/6481195/webrev.00/
Issue:
Invalid ListSelectionEvents are being fired, when the data is added after the clear() function has been called on DefaultListModel. This only happens when the index 0 was selected before calling clear.
When the index 0 is selected on a JList and clear() function is called, anchor and lead are not being updated properly in DefaultSelectionModel as they are not being reset to -1 inside the removeIndexInterval() function. Because of this, when new elements are added in model, a ListSelectionEvent is fired from insertIndexInterval() function.
Fix:
The code inside removeIndexInterval function handles the case when 0 index is selected in special way. Removed that piece of code.
Note:
This also fixes https://bugs.openjdk.java.net/browse/JDK-4334792 partially when removeAllElements or clear() is called on DefaultListModel.
Regards
Pankaj Bansal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/swing-dev/attachments/20180122/bb3e0be3/attachment.html>
More information about the swing-dev
mailing list