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
.
String selected = jlist.getSelectedItem().toString();
The above code gives me the selected JList
value. But this code has to be placed inside a button event, where when i click the button it will get the JList value an assign it to the JLabel
.
But, what i want to do is, as soon as the user clicks an item of the JList
to update the JLabel
in real time. (without having to click buttons to fire an action)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…