List of usage examples for javax.swing DefaultListSelectionModel isSelectedIndex
public boolean isSelectedIndex(int index)
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 . ja v a2 s. co m*/ }); list.setSelectionModel(m); System.out.println(m.isSelectedIndex(0)); add(pane, BorderLayout.NORTH); }