Skip to content

Instantly share code, notes, and snippets.

@Fuud
Created September 15, 2013 13:52
Show Gist options
  • Save Fuud/6570945 to your computer and use it in GitHub Desktop.
Save Fuud/6570945 to your computer and use it in GitHub Desktop.
import javax.swing.*;
/* @test
* @bug 6921688
* @summary Lead selection index should be cleared after selection was erased
* @author Fedor Bobin
* @run main DefaultListSelectionModelTest
*/
public class DefaultListSelectionModelTest {
public static void main(String[] args) {
final DefaultListSelectionModel defaultListSelectionModel = new DefaultListSelectionModel();
defaultListSelectionModel.setSelectionInterval(0, 0);
if (defaultListSelectionModel.getLeadSelectionIndex() != 0) {
throw new AssertionError("Was selected only item 0 but lead selected index = " +
defaultListSelectionModel.getLeadSelectionIndex());
}
defaultListSelectionModel.removeIndexInterval(0, 0);
if (!defaultListSelectionModel.isSelectionEmpty()) {
throw new AssertionError("Selection should be empty");
}
if (defaultListSelectionModel.getLeadSelectionIndex() != -1) {
throw new AssertionError("Selection is empty => there is no lead selected index => " +
"lead selected index must be -1 but lead selected index = " +
defaultListSelectionModel.getLeadSelectionIndex());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment