List of utility methods to do JList Select
void | setSelectedValue(JList list, Object value) set Selected Value list.setSelectedValue(value, true); |
void | setSelectedValues(JList jList, Object[] values) set Selected Values int[] indices = new int[values.length]; for (int i = 0; i < values.length; i++) indices[i] = indexOf(jList, values[i]); jList.setSelectedIndices(indices); |
void | setSelection(JList list, Object element) set Selection for (int i = 0; i < list.getModel().getSize(); i++) { Object value = (Object) list.getModel().getElementAt(i); if (value == element) { list.setSelectedIndex(i); list.scrollRectToVisible(list.getCellBounds(i, i)); return; |
void | updateSelectionAfterItemMoved(ListSelectionModel selectionModel, int[] previousSelection, int previousIndex, int newIndex) update Selection After Item Moved selectionModel.setValueIsAdjusting(true); selectionModel.clearSelection(); for (int index : previousSelection) { int insertion; if (index == previousIndex) { insertion = newIndex; } else { insertion = index; ... |