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

Reply via email to