List of usage examples for javax.swing DefaultListSelectionModel getLeadSelectionIndex
@Transient public int getLeadSelectionIndex()
From source file:Main.java
public Main() { setLayout(new BorderLayout()); list = new JList(label); JScrollPane pane = new JScrollPane(list); DefaultListSelectionModel m = new DefaultListSelectionModel(); list.setSelectionModel(m);//from w ww . ja v a 2 s . c om System.out.println(m.getLeadSelectionIndex()); add(pane, BorderLayout.NORTH); }