List of usage examples for javax.swing ListSelectionModel setAnchorSelectionIndex
void setAnchorSelectionIndex(int index);
From source file:Main.java
/** * Set the lead and anchor without affecting selection. *///www . j a va2 s. c o m public static void setLeadAnchorWithoutSelection(ListSelectionModel model, int lead, int anchor) { if (anchor == -1) { anchor = lead; } if (lead == -1) { model.setAnchorSelectionIndex(-1); model.setLeadSelectionIndex(-1); } else { if (model.isSelectedIndex(lead)) { model.addSelectionInterval(lead, lead); } else { model.removeSelectionInterval(lead, lead); } model.setAnchorSelectionIndex(anchor); } }