JList.addSelectionInterval(int anchor, int lead) has the following syntax.
public void addSelectionInterval(int anchor, int lead)
In the following code shows how to use JList.addSelectionInterval(int anchor, int lead) method.
// w ww. j av a 2s. c o 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); int start = 2; int end = 2; list.addSelectionInterval(start, end); } }