List of usage examples for javax.swing DefaultListSelectionModel removeListSelectionListener
public void removeListSelectionListener(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.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); m.setLeadAnchorNotificationEnabled(false); list.setSelectionModel(m);//from w ww.j av a2 s . c om ListSelectionListener lis = new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { System.out.println(e.toString()); } }; m.addListSelectionListener(lis); m.removeListSelectionListener(lis); add(pane, BorderLayout.NORTH); }