A more descriptive variant of java.awt.event.MouseEvent#getClickCount() == 2. - Java Swing

Java examples for Swing:Mouse Event

Description

A more descriptive variant of java.awt.event.MouseEvent#getClickCount() == 2.

Demo Code


//package com.java2s;
import java.awt.event.MouseEvent;

public class Main {
    /**//ww w.  j  a v a2  s .c  o m
     * A more descriptive variant of
     * {@code java.awt.event.MouseEvent#getClickCount()} == 2.
     *
     * @param  evt  mouse event
     * @return true, if the user clicked twice or more often
     */
    public static boolean isDoubleClick(MouseEvent evt) {
        if (evt == null) {
            throw new NullPointerException("evt == null");
        }

        return evt.getClickCount() >= 2;
    }
}

Related Tutorials