List of usage examples for javax.swing.event ListSelectionEvent toString
public String toString()
From source file:Main.java
public Main() { setLayout(new BorderLayout()); list = new JList(label); JButton button = new JButton("Print"); JScrollPane pane = new JScrollPane(list); DefaultListSelectionModel m = new DefaultListSelectionModel(); m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); m.setLeadAnchorNotificationEnabled(false); list.setSelectionModel(m);//from w ww . ja va 2 s . c o m list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { System.out.println(e.toString()); } }); button.addActionListener(new PrintListener()); add(pane, BorderLayout.NORTH); add(button, BorderLayout.SOUTH); }
From source file:SimpleList2.java
public SimpleList2() { setLayout(new BorderLayout()); list = new JList(label); JButton button = new JButton("Print"); JScrollPane pane = new JScrollPane(list); DefaultListSelectionModel m = new DefaultListSelectionModel(); m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); m.setLeadAnchorNotificationEnabled(false); list.setSelectionModel(m);//from w w w .java2 s. c o m list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { System.out.println(e.toString()); } }); button.addActionListener(new PrintListener()); add(pane, BorderLayout.NORTH); add(button, BorderLayout.SOUTH); }