On 19 Mar 2006 16:02:14 -0800, "" <>
wrote, quoted or indirectly quoted someone who said :
>I have a JList of objects, I know how to get an event of an item is
>selected, but how do i receive an event if an item is double clicked?
quoting from the JavaDoc
JList doesn't provide any special support for handling double or
triple (or N) mouse clicks however it's easy to handle them using a
MouseListener. Use the JList method locationToIndex() to determine
what cell was clicked. For example:
final JList list = new JList(dataModel);
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
int index = list.locationToIndex(e.getPoint());
System.out.println("Double clicked on Item " + index);
}
}
};
list.addMouseListener(mouseListener);
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.