Returns, whether the left mouse button was clicked. - Java Swing

Java examples for Swing:Mouse Event

Description

Returns, whether the left mouse button was clicked.

Demo Code


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

public class Main {
    /**/*from   ww  w  .j a v a  2s .  co  m*/
     * Returns, whether the left mouse button was clicked.
     *
     * @param  evt  mouse event
     * @return true if the left mouse button was clicked
     */
    public static boolean isLeftClick(MouseEvent evt) {
        if (evt == null) {
            throw new NullPointerException("evt == null");
        }

        return evt.getButton() == MouseEvent.BUTTON1;
    }
}

Related Tutorials