FileDocCategorySizeDatePackage
TimingIsEverything.javaAPI DocExample848Tue Dec 12 18:57:44 GMT 2000None

TimingIsEverything

public class TimingIsEverything extends Applet

Fields Summary
public long
firstClickTime
public String
displayStr
Constructors Summary
Methods Summary
public voidinit()


       
        displayStr = "Double Click Me";
    
public booleanmouseDown(java.awt.Event evt, int x, int y)

        long clickTime = System.currentTimeMillis();
        long clickInterval = clickTime - firstClickTime;
        if (clickInterval < 200) {
            displayStr = "Double Click!! (Interval = " + clickInterval + ")";
            firstClickTime = 0;
        } else {
            displayStr = "Single Click!!";
            firstClickTime = clickTime;
        }
        repaint();
        return true;
    
public voidpaint(java.awt.Graphics g)

        g.drawRect(0, 0, size().width-1, size().height-1);
        g.drawString(displayStr, 40, 30);