I want to know how can we perform action when mouse is double clicked in a component.
+5
A:
public void mouseClicked(MouseEvent event)
{
if (event.getClickCount() == 2) {
System.out.println("double clicked)";
}
}
kaliatech
2010-10-29 12:09:02
+2
A:
Assuming you mean in Swing, assign a MouseListener to your Component:
addMouseListener(new MouseAdapter(){
@Override
public void mouseClicked(MouseEvent e){
if(e.getClickCount()==2){
// your code here
}
}
});
Reference:
- Java Tutorial: How to write a Mouse Listener
seanizer
2010-10-29 12:16:07