List of usage examples for javax.swing DefaultListSelectionModel moveLeadSelectionIndex
public void moveLeadSelectionIndex(int leadIndex)
From source file:Main.java
public Main() { setLayout(new BorderLayout()); list = new JList(label); JScrollPane pane = new JScrollPane(list); DefaultListSelectionModel m = new DefaultListSelectionModel(); m.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { System.out.println(e.toString()); }//from w w w . j av a 2 s .com }); list.setSelectionModel(m); m.moveLeadSelectionIndex(1); add(pane, BorderLayout.NORTH); }