List of usage examples for javax.swing DefaultListSelectionModel addListSelectionListener
public void addListSelectionListener(ListSelectionListener l)
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()); }/* ww w.j av a2s. com*/ }); list.setSelectionModel(m); System.out.println(m.isSelectionEmpty()); add(pane, BorderLayout.NORTH); }
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 a v a 2s. c o m*/ }); list.setSelectionModel(m); System.out.println(m.isLeadAnchorNotificationEnabled()); add(pane, BorderLayout.NORTH); }
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 .java2 s . c o m*/ }); list.setSelectionModel(m); m.setLeadSelectionIndex(1); add(pane, BorderLayout.NORTH); }
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 ww . ja va2 s . c o m }); list.setSelectionModel(m); System.out.println(m.getMinSelectionIndex()); add(pane, BorderLayout.NORTH); }
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()); }//w w w . j a v a 2 s .co m }); list.setSelectionModel(m); System.out.println(m.getValueIsAdjusting()); add(pane, BorderLayout.NORTH); }
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 www . ja v a 2s . co m*/ }); list.setSelectionModel(m); System.out.println(m.getSelectionMode() == ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); add(pane, BorderLayout.NORTH); }
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 ww . j ava 2 s. c o m*/ m.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { System.out.println(e.toString()); } }); add(pane, BorderLayout.NORTH); }
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 ww . j av a 2 s . co m*/ ListSelectionListener lis = new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { System.out.println(e.toString()); } }; m.addListSelectionListener(lis); m.removeListSelectionListener(lis); add(pane, BorderLayout.NORTH); }