JList.setSelectionInterval(int anchor, int lead) has the following syntax.
public void setSelectionInterval(int anchor, int lead)
In the following code shows how to use JList.setSelectionInterval(int anchor, int lead) method.
// w w w. j ava2 s . co m import javax.swing.JList; public class Main { public static void main(String[] argv) throws Exception { String[] items = { "A", "B", "C", "D" }; JList list = new JList(items); // Select the second item int start = 1; int end = 1; list.setSelectionInterval(start, end); } }