I have a JList, where i am displaying some ID\'s. I want to capture the ID the user clicked and dis play it on a JLabel.
JList
JLabel
String sel
Use a ListSelectionListener:
ListSelectionListener
JList list = new JList(...); list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (!evt.getValueIsAdjusting()) { // code here } } });