SelectionInfo () { final ListSelectionModel selectionModel = myList.getSelectionModel(); final ArrayList<Object> selectedObjects = new ArrayList<>(); final int[] selectedIndices = myList.getSelectedIndices(); final int leadSelectionIndex = selectionModel.getLeadSelectionIndex(); Object leadSelection = null; for (final int index : selectedIndices) { if (index < myList.getModel().getSize()) { final Object o = myModel.getElementAt(index); selectedObjects.add(o); if (index == leadSelectionIndex) { leadSelection = o; } } } return new SelectionInfo(selectedObjects, leadSelectionIndex, leadSelection); }