mrpatel
asked on
DoubleClick event in JAVA
Hi all,
I am new in Java Graphincs. I have a JList of strings. Now when a user Double clicks on one of the items in list, I need to perform some action. How do I Create the DoubleClick Event?
Thanks,
-Mehul
I am new in Java Graphincs. I have a JList of strings. Now when a user Double clicks on one of the items in list, I need to perform some action. How do I Create the DoubleClick Event?
Thanks,
-Mehul
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The following is from the 1.4.1 API documentation for JList:
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.get Point());
System.out.println("Double clicked on Item " + index);
}
}
};
list.addMouseListener(mous eListener) ;
Note that in this example the dataList is final because it's referred to by the anonymous MouseListener class.
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.get
System.out.println("Double
}
}
};
list.addMouseListener(mous
Note that in this example the dataList is final because it's referred to by the anonymous MouseListener class.
mrpatel:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
a dblclick would be
press
release
press
release
You prpbally want to time the clicks, so you can tell
that it's an actuall dblclick,
vs. click ..wait ten minutes... click