void (final SelectionInfo selection) { final ArrayList<Object> selectedObjects = selection.mySelectedObjects; final ListSelectionModel selectionModel = myList.getSelectionModel(); selectionModel.clearSelection(); if (!selectedObjects.isEmpty()) { int leadIndex = -1; for (int i = 0; i < selectedObjects.size(); i++) { final Object o = selectedObjects.get(i); final int index = myModel.indexOf(o); if (index > -1) { selectionModel.addSelectionInterval(index, index); if (o == selection.myLeadSelection) { leadIndex = index; } } } if (selectionModel.getMinSelectionIndex() == -1) { final int toSelect = Math.min(selection.myLeadSelectionIndex, myModel.getSize() - 1); if (toSelect >= 0) { myList.setSelectedIndex(toSelect); } } else if (leadIndex != -1) { selectionModel.setLeadSelectionIndex(leadIndex); } } }