Example usage for java.awt Event MOUSE_DOWN

List of usage examples for java.awt Event MOUSE_DOWN

Introduction

In this page you can find the example usage for java.awt Event MOUSE_DOWN.

Prototype

int MOUSE_DOWN

To view the source code for java.awt Event MOUSE_DOWN.

Click Source Link

Document

The user has pressed the mouse button.

Usage

From source file:Animator.java

/**
 * Pause the thread when the user clicks the mouse in the applet. If the
 * thread has stopped (as in a non-repeat performance), restart it.
 *//*from  w  w  w  . j av a2s. c o  m*/
public boolean handleEvent(Event evt) {
    if (evt.id == Event.MOUSE_DOWN) {
        if (loaded) {
            if (engine != null && engine.isAlive()) {
                if (userPause) {
                    engine.resume();
                    startPlaying();
                } else {
                    engine.suspend();
                    stopPlaying();
                }
                userPause = !userPause;
            } else {
                userPause = false;
                setFrameNum(0);
                engine = new Thread(this);
                engine.start();
            }
        }
        return true;
    } else {
        return super.handleEvent(evt);
    }
}