List of usage examples for javax.swing DefaultListSelectionModel addSelectionInterval
public void addSelectionInterval(int index0, int index1)
From source file:Main.java
public Main() { setLayout(new BorderLayout()); list = new JList(label); JScrollPane pane = new JScrollPane(list); DefaultListSelectionModel m = new DefaultListSelectionModel(); m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); m.setLeadAnchorNotificationEnabled(false); list.setSelectionModel(m);// w w w . ja v a 2s. c o m m.addSelectionInterval(1, 1); add(pane, BorderLayout.NORTH); }