import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JList;
public class Main {
public static void main(String[] argv) throws Exception {
String[] items = { "A", "B", "C", "D" };
JList list = new JList(items);
list.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent evt) {
JList list = (JList) evt.getSource();
if (evt.getClickCount() == 2) { // Double-click
int index = list.locationToIndex(evt.getPoint());
} else if (evt.getClickCount() == 3) { // Triple-click
int index = list.locationToIndex(evt.getPoint());
}
}
});
}
}
|