List of usage examples for javax.swing JList getLeadSelectionIndex
@BeanProperty(bound = false, description = "The lead selection index.") public int getLeadSelectionIndex()
From source file:Main.java
public static void main(final String args[]) { String labels[] = { "A", "B", "C", "D", "E" }; JFrame frame = new JFrame("Sizing Samples"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist1 = new JList(); jlist1.setListData(labels);//from w w w . j a v a 2 s .co m jlist1.setVisibleRowCount(4); JScrollPane scrollPane1 = new JScrollPane(jlist1); frame.add(scrollPane1, BorderLayout.NORTH); jlist1.getLeadSelectionIndex(); frame.setSize(300, 350); frame.setVisible(true); }
From source file:gtu._work.mvn.MavenRepositoryUI.java
void defaultJListClick(final JList jList, MouseEvent evt) { if (jList.getLeadSelectionIndex() == -1) { return;/*from ww w . j a va2 s. c o m*/ } //? if (jList.getSelectedValues().length > 1) { defaultPopupMenu(ListUtil.getList(jList.getSelectedValues(), PomFile.class), jList, evt); return; } //? final PomFile pomFile = (PomFile) JListUtil.getLeadSelectionObject(jList); this.defaultPopupMenu(Arrays.asList(pomFile), jList, evt); if (JListUtil.newInstance(jList).isCorrectMouseClick(evt)) { this.showPomInfo(pomFile); } }