Example usage for java.awt.event MouseEvent hashCode

List of usage examples for java.awt.event MouseEvent hashCode

Introduction

In this page you can find the example usage for java.awt.event MouseEvent hashCode.

Prototype

@HotSpotIntrinsicCandidate
public native int hashCode();

Source Link

Document

Returns a hash code value for the object.

Usage

From source file:SWTUtils.java

/**
 * Creates an AWT <code>MouseEvent</code> from a swt event.
 * This method helps passing SWT mouse event to awt components.
 * @param event The swt event.//from  w w w.  jav a 2s.  co  m
 * @return A AWT mouse event based on the given SWT event.
 */
public static MouseEvent toAwtMouseEvent(org.eclipse.swt.events.MouseEvent event) {
    int button = MouseEvent.NOBUTTON;
    switch (event.button) {
    case 1:
        button = MouseEvent.BUTTON1;
        break;
    case 2:
        button = MouseEvent.BUTTON2;
        break;
    case 3:
        button = MouseEvent.BUTTON3;
        break;
    }
    int modifiers = 0;
    if ((event.stateMask & SWT.CTRL) != 0) {
        modifiers |= InputEvent.CTRL_DOWN_MASK;
    }
    if ((event.stateMask & SWT.SHIFT) != 0) {
        modifiers |= InputEvent.SHIFT_DOWN_MASK;
    }
    if ((event.stateMask & SWT.ALT) != 0) {
        modifiers |= InputEvent.ALT_DOWN_MASK;
    }
    MouseEvent awtMouseEvent = new MouseEvent(DUMMY_PANEL, event.hashCode(), event.time, modifiers, event.x,
            event.y, 1, false, button);
    return awtMouseEvent;
}