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);
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);