java.awt.event.InputEvent#BUTTON2_MASK()源码实例Demo

下面列出了java.awt.event.InputEvent#BUTTON2_MASK() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-8-source   文件: Util.java
/**
 * Drags from one point to another with the specified mouse button pressed.
 *
 * @param robot a robot to use for moving the mouse, etc.
 * @param startPoint a start point of the drag
 * @param endPoint an end point of the drag
 * @param button one of {@code InputEvent.BUTTON1_MASK},
 *     {@code InputEvent.BUTTON2_MASK}, {@code InputEvent.BUTTON3_MASK}
 *
 * @throws IllegalArgumentException if {@code button} is not one of
 *     {@code InputEvent.BUTTON1_MASK}, {@code InputEvent.BUTTON2_MASK},
 *     {@code InputEvent.BUTTON3_MASK}
 */
public static void drag(Robot robot, Point startPoint, Point endPoint, int button) {
    if (!(button == InputEvent.BUTTON1_MASK || button == InputEvent.BUTTON2_MASK
            || button == InputEvent.BUTTON3_MASK))
    {
        throw new IllegalArgumentException("invalid mouse button");
    }

    robot.mouseMove(startPoint.x, startPoint.y);
    robot.mousePress(button);
    try {
        mouseMove(robot, startPoint, endPoint);
    } finally {
        robot.mouseRelease(button);
    }
}
 
源代码2 项目: dragonwell8_jdk   文件: DragSourceDragEvent.java
/**
 * Sets new modifiers by the old ones.
 * The mouse modifiers have higher priority than overlaying key
 * modifiers.
 */
private void setNewModifiers() {
    if ((gestureModifiers & InputEvent.BUTTON1_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON1_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON2_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON2_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON3_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON3_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.SHIFT_MASK) != 0) {
        gestureModifiers |= InputEvent.SHIFT_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.CTRL_MASK) != 0) {
        gestureModifiers |= InputEvent.CTRL_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
        gestureModifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
    }
}
 
源代码3 项目: dragonwell8_jdk   文件: DragSourceDragEvent.java
/**
 * Sets old modifiers by the new ones.
 */
private void setOldModifiers() {
    if ((gestureModifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON1_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON2_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON3_MASK;
    }
    if ((gestureModifiers & InputEvent.SHIFT_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.SHIFT_MASK;
    }
    if ((gestureModifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.CTRL_MASK;
    }
    if ((gestureModifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.ALT_GRAPH_MASK;
    }
}
 
源代码4 项目: openjdk-jdk9   文件: Robot.java
@SuppressWarnings("deprecation")
private static synchronized void initLegalButtonMask() {
    if (LEGAL_BUTTON_MASK != 0) return;

    int tmpMask = 0;
    if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
        if (Toolkit.getDefaultToolkit() instanceof SunToolkit) {
            final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
            for (int i = 0; i < buttonsNumber; i++){
                tmpMask |= InputEvent.getMaskForButton(i+1);
            }
        }
    }
    tmpMask |= InputEvent.BUTTON1_MASK|
        InputEvent.BUTTON2_MASK|
        InputEvent.BUTTON3_MASK|
        InputEvent.BUTTON1_DOWN_MASK|
        InputEvent.BUTTON2_DOWN_MASK|
        InputEvent.BUTTON3_DOWN_MASK;
    LEGAL_BUTTON_MASK = tmpMask;
}
 
源代码5 项目: openjdk-8   文件: Robot.java
private static synchronized void initLegalButtonMask() {
    if (LEGAL_BUTTON_MASK != 0) return;

    int tmpMask = 0;
    if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
        if (Toolkit.getDefaultToolkit() instanceof SunToolkit) {
            final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
            for (int i = 0; i < buttonsNumber; i++){
                tmpMask |= InputEvent.getMaskForButton(i+1);
            }
        }
    }
    tmpMask |= InputEvent.BUTTON1_MASK|
        InputEvent.BUTTON2_MASK|
        InputEvent.BUTTON3_MASK|
        InputEvent.BUTTON1_DOWN_MASK|
        InputEvent.BUTTON2_DOWN_MASK|
        InputEvent.BUTTON3_DOWN_MASK;
    LEGAL_BUTTON_MASK = tmpMask;
}
 
源代码6 项目: jdk8u-jdk   文件: Util.java
/**
 * Drags from one point to another with the specified mouse button pressed.
 *
 * @param robot a robot to use for moving the mouse, etc.
 * @param startPoint a start point of the drag
 * @param endPoint an end point of the drag
 * @param button one of {@code InputEvent.BUTTON1_MASK},
 *     {@code InputEvent.BUTTON2_MASK}, {@code InputEvent.BUTTON3_MASK}
 *
 * @throws IllegalArgumentException if {@code button} is not one of
 *     {@code InputEvent.BUTTON1_MASK}, {@code InputEvent.BUTTON2_MASK},
 *     {@code InputEvent.BUTTON3_MASK}
 */
public static void drag(Robot robot, Point startPoint, Point endPoint, int button) {
    if (!(button == InputEvent.BUTTON1_MASK || button == InputEvent.BUTTON2_MASK
            || button == InputEvent.BUTTON3_MASK))
    {
        throw new IllegalArgumentException("invalid mouse button");
    }

    robot.mouseMove(startPoint.x, startPoint.y);
    robot.mousePress(button);
    try {
        mouseMove(robot, startPoint, endPoint);
    } finally {
        robot.mouseRelease(button);
    }
}
 
源代码7 项目: Java8CN   文件: DragSourceDragEvent.java
/**
 * Sets old modifiers by the new ones.
 */
private void setOldModifiers() {
    if ((gestureModifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON1_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON2_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON3_MASK;
    }
    if ((gestureModifiers & InputEvent.SHIFT_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.SHIFT_MASK;
    }
    if ((gestureModifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.CTRL_MASK;
    }
    if ((gestureModifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.ALT_GRAPH_MASK;
    }
}
 
源代码8 项目: jdk8u-jdk   文件: Robot.java
private static synchronized void initLegalButtonMask() {
    if (LEGAL_BUTTON_MASK != 0) return;

    int tmpMask = 0;
    if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
        if (Toolkit.getDefaultToolkit() instanceof SunToolkit) {
            final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
            for (int i = 0; i < buttonsNumber; i++){
                tmpMask |= InputEvent.getMaskForButton(i+1);
            }
        }
    }
    tmpMask |= InputEvent.BUTTON1_MASK|
        InputEvent.BUTTON2_MASK|
        InputEvent.BUTTON3_MASK|
        InputEvent.BUTTON1_DOWN_MASK|
        InputEvent.BUTTON2_DOWN_MASK|
        InputEvent.BUTTON3_DOWN_MASK;
    LEGAL_BUTTON_MASK = tmpMask;
}
 
源代码9 项目: SikuliX1   文件: Mouse.java
private static String getClickMsg(Location loc, int buttons, int modifiers, boolean dblClick, long duration) {
  String msg = "";
  if (modifiers != 0 && modifiers < 16) {
    msg += KeyEvent.getKeyModifiersText(modifiers).replaceAll(" ", "") + " + ";
  }
  if (buttons == InputEvent.BUTTON1_MASK && !dblClick) {
    msg += "CLICK";
  }
  if (buttons == InputEvent.BUTTON1_MASK && dblClick) {
    msg += "DOUBLE CLICK";
  }
  if (buttons == InputEvent.BUTTON3_MASK) {
    msg += "RIGHT CLICK";
  } else if (buttons == InputEvent.BUTTON2_MASK) {
    msg += "MID CLICK";
  }
  msg += String.format(" on %s (%d msec)", loc, duration);
  return msg;
}
 
源代码10 项目: JDKSourceCode1.8   文件: Robot.java
private static synchronized void initLegalButtonMask() {
    if (LEGAL_BUTTON_MASK != 0) return;

    int tmpMask = 0;
    if (Toolkit.getDefaultToolkit().areExtraMouseButtonsEnabled()){
        if (Toolkit.getDefaultToolkit() instanceof SunToolkit) {
            final int buttonsNumber = ((SunToolkit)(Toolkit.getDefaultToolkit())).getNumberOfButtons();
            for (int i = 0; i < buttonsNumber; i++){
                tmpMask |= InputEvent.getMaskForButton(i+1);
            }
        }
    }
    tmpMask |= InputEvent.BUTTON1_MASK|
        InputEvent.BUTTON2_MASK|
        InputEvent.BUTTON3_MASK|
        InputEvent.BUTTON1_DOWN_MASK|
        InputEvent.BUTTON2_DOWN_MASK|
        InputEvent.BUTTON3_DOWN_MASK;
    LEGAL_BUTTON_MASK = tmpMask;
}
 
源代码11 项目: marathonv5   文件: RobotDevice.java
@Override
public void click(Component component, Buttons button, int clickCount, int xoffset, int yoffset) {
    ensureVisible(component, new Rectangle(xoffset, yoffset, 50, 50));
    int b = InputEvent.BUTTON1_MASK;
    if (button.getButton() == 0) {
        b = InputEvent.BUTTON1_MASK;
    } else if (button.getButton() == 1) {
        b = InputEvent.BUTTON2_MASK;
    } else if (button.getButton() == 2) {
        b = InputEvent.BUTTON3_MASK;
    }
    Point compLocation = component.getLocationOnScreen();
    int x = compLocation.x + xoffset;
    int y = compLocation.y + yoffset;
    robotXmouseMove(x, y);
    for (int i = 0; i < clickCount; i++) {
        robotXmousePress(b);
        robotXmouseRelease(b);
    }
}
 
源代码12 项目: jdk8u_jdk   文件: DragSourceDragEvent.java
/**
 * Sets new modifiers by the old ones.
 * The mouse modifiers have higher priority than overlaying key
 * modifiers.
 */
private void setNewModifiers() {
    if ((gestureModifiers & InputEvent.BUTTON1_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON1_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON2_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON2_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON3_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON3_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.SHIFT_MASK) != 0) {
        gestureModifiers |= InputEvent.SHIFT_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.CTRL_MASK) != 0) {
        gestureModifiers |= InputEvent.CTRL_DOWN_MASK;
    }
    if ((gestureModifiers & InputEvent.ALT_GRAPH_MASK) != 0) {
        gestureModifiers |= InputEvent.ALT_GRAPH_DOWN_MASK;
    }
}
 
源代码13 项目: openjdk-jdk8u   文件: Util.java
/**
 * Drags from one point to another with the specified mouse button pressed.
 *
 * @param robot a robot to use for moving the mouse, etc.
 * @param startPoint a start point of the drag
 * @param endPoint an end point of the drag
 * @param button one of {@code InputEvent.BUTTON1_MASK},
 *     {@code InputEvent.BUTTON2_MASK}, {@code InputEvent.BUTTON3_MASK}
 *
 * @throws IllegalArgumentException if {@code button} is not one of
 *     {@code InputEvent.BUTTON1_MASK}, {@code InputEvent.BUTTON2_MASK},
 *     {@code InputEvent.BUTTON3_MASK}
 */
public static void drag(Robot robot, Point startPoint, Point endPoint, int button) {
    if (!(button == InputEvent.BUTTON1_MASK || button == InputEvent.BUTTON2_MASK
            || button == InputEvent.BUTTON3_MASK))
    {
        throw new IllegalArgumentException("invalid mouse button");
    }

    robot.mouseMove(startPoint.x, startPoint.y);
    robot.mousePress(button);
    try {
        mouseMove(robot, startPoint, endPoint);
    } finally {
        robot.mouseRelease(button);
    }
}
 
源代码14 项目: JDKSourceCode1.8   文件: DragSourceDragEvent.java
/**
 * Sets old modifiers by the new ones.
 */
private void setOldModifiers() {
    if ((gestureModifiers & InputEvent.BUTTON1_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON1_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON2_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON2_MASK;
    }
    if ((gestureModifiers & InputEvent.BUTTON3_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.BUTTON3_MASK;
    }
    if ((gestureModifiers & InputEvent.SHIFT_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.SHIFT_MASK;
    }
    if ((gestureModifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.CTRL_MASK;
    }
    if ((gestureModifiers & InputEvent.ALT_GRAPH_DOWN_MASK) != 0) {
        gestureModifiers |= InputEvent.ALT_GRAPH_MASK;
    }
}
 
源代码15 项目: jmg   文件: StaveActionHandler.java
public void mouseClicked(MouseEvent e) {
    if ((((e.getModifiers() & InputEvent.BUTTON2_MASK) != 0)) && 
            inNoteArea(e)) {
        searchForSelectedNote(e);
        if ((selectedNote >= 0) && 
            (selectedNote < theApp.getPhrase().size())) {
            noteContextMenu.show(theApp, e.getX(), e.getY());                            
        }                    
    }
}
 
源代码16 项目: Spark   文件: StringUtils.java
public static String keyStroke2String(KeyStroke key) {
StringBuilder s = new StringBuilder(50);
int m = key.getModifiers();

if ((m & (InputEvent.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK)) != 0) {
    s.append("shift ");
}
if ((m & (InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK)) != 0) {
    s.append("ctrl ");
}
if ((m & (InputEvent.META_DOWN_MASK | InputEvent.META_MASK)) != 0) {
    s.append("meta ");
}
if ((m & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK)) != 0) {
    s.append("alt ");
}
if ((m & (InputEvent.BUTTON1_DOWN_MASK | InputEvent.BUTTON1_MASK)) != 0) {
    s.append("button1 ");
}
if ((m & (InputEvent.BUTTON2_DOWN_MASK | InputEvent.BUTTON2_MASK)) != 0) {
    s.append("button2 ");
}
if ((m & (InputEvent.BUTTON3_DOWN_MASK | InputEvent.BUTTON3_MASK)) != 0) {
    s.append("button3 ");
}

switch (key.getKeyEventType()) {
case KeyEvent.KEY_TYPED:
    s.append("typed ");
    s.append(key.getKeyChar()).append(" ");
    break;
case KeyEvent.KEY_PRESSED:
    s.append("pressed ");
    s.append(getKeyText(key.getKeyCode())).append(" ");
    break;
case KeyEvent.KEY_RELEASED:
    s.append("released ");
    s.append(getKeyText(key.getKeyCode())).append(" ");
    break;
default:
    s.append("unknown-event-type ");
    break;
}

return s.toString();
   }
 
源代码17 项目: jdk8u-dev-jdk   文件: bug7146377.java
private static boolean oldIsMiddleMouseButton(MouseEvent e) {
    return ((e.getModifiers() & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK);
}
 
源代码18 项目: TencentKona-8   文件: bug7146377.java
private static boolean oldIsMiddleMouseButton(MouseEvent e) {
    return ((e.getModifiers() & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK);
}
 
源代码19 项目: jdk8u-jdk   文件: bug7146377.java
private static boolean oldIsMiddleMouseButton(MouseEvent e) {
    return ((e.getModifiers() & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK);
}
 
源代码20 项目: openjdk-jdk8u-backup   文件: bug7146377.java
private static boolean oldIsMiddleMouseButton(MouseEvent e) {
    return ((e.getModifiers() & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK);
}