Wed Feb 06, 2013 9:09 pm
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;
}
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.