Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;

public class Main {
    /**
     * Check to see if the event is for the left mouse button and the Alt key is pressed.
     * Also allows the right mouse button with the control key down. This is so it can
     * work via Citrix Receiver.
     *
     * @param event
     * @return
     */
    static boolean isLeftButtonAndAltDown(final MouseEvent event) {
        if (event.getButton() == MouseEvent.BUTTON1) {
            return isAltDown(event);
        } else if (event.getButton() == MouseEvent.BUTTON3) {
            return isControlDown(event);
        } else {
            return false;
        }
    }

    static boolean isAltDown(final InputEvent event) {
        final int modifiersEx = event.getModifiersEx();
        final int flag = modifiersEx & InputEvent.ALT_DOWN_MASK;
        return flag != 0;
    }

    static boolean isControlDown(final InputEvent event) {
        final int modifiersEx = event.getModifiersEx();
        final int flag = modifiersEx & InputEvent.CTRL_DOWN_MASK;
        return flag != 0;
    }
}