I have a JList
with a DefaultListModel
.
How I can make an item in a JList
react to double-click event?
(based on Mohamed Saligh, the accepted response)
If you are using NetBeans
Select the JList > Events window > mouseClicked
private void jListNicknamesMouseClicked(java.awt.event.MouseEvent evt) {
JList list = (JList)evt.getSource();
if (evt.getClickCount() == 2) {
int index = list.locationToIndex(evt.getPoint());
System.out.println("index: "+index);
}
}