Switch to full style
General Java code examples
Post a reply

get time difference between to mouse-clicks-double clicks

Wed Feb 06, 2013 9:09 pm

get time difference between to mouse-clicks
java code
import java.awt.Graphics;

public class HandleTimeApplet extends java.applet.Applet {

public long firstClickTime = 0;
public String msgToDisplay;

public void init() {
msgToDisplay = "Double Click";
}
public void paint(Graphics g) {
g.drawRect(0, 0, size().width-1, size().height-1);
g.drawString(msgToDisplay, 40, 30);
}
public boolean mouseDown(java.awt.Event evt, int x, int y) {
long clickTime = System.currentTimeMillis();
long clickInterval = clickTime - firstClickTime;
if (clickInterval < 200) {
msgToDisplay = "Double Click!! (Interval = " + clickInterval + ")";
firstClickTime = 0;
} else {
msgToDisplay = "Single Click!!";
firstClickTime = clickTime;
}
repaint();
return true;
}
}




Post a reply
  Related Posts  to : get time difference between to mouse-clicks-double clicks
 draw any number of lines on mouse clicks     -  
 draw any number of circles using mouse clicks     -  
 Applet get mouse clicks and draw circle     -  
 Draw Cardinal Spline With Mouse Clicks Points     -  
 Draw curves using Hermite Curve equations with mouse clicks     -  
 show the locations of clicks on the image     -  
 avoid multiple submit clicks using javascript     -  
 How to track clicks on hash links from Google analytic     -  
 difference between preemptive scheduling and time slicing     -  
 double value be cast to a byte     -