List of usage examples for java.awt.event InputEvent BUTTON2_DOWN_MASK
int BUTTON2_DOWN_MASK
To view the source code for java.awt.event InputEvent BUTTON2_DOWN_MASK.
Click Source Link
From source file:Main.java
static boolean isMiddleDown(final InputEvent event) { final int modifiersEx = event.getModifiersEx(); final int flag = modifiersEx & InputEvent.BUTTON2_DOWN_MASK; return flag != 0; }
From source file:Main.java
/** * Serializes a Keystrike to a String.// w ww .j av a 2 s . com * It can then be fed into KeyStroke.getKeyStroke(String). * * See: http://www.exampledepot.com/egs/javax.swing/Key2Str.html */ public static String keyStroke2String(KeyStroke key) { StringBuffer s = new StringBuffer(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: if (key.getKeyChar() == Character.MAX_VALUE) { s.append("unknown-typed-key "); break; } s.append("typed ").append(key.getKeyChar()).append(" "); break; case KeyEvent.KEY_PRESSED: s.append("pressed ").append(getKeyText(key.getKeyCode())).append(" "); break; case KeyEvent.KEY_RELEASED: s.append("released ").append(getKeyText(key.getKeyCode())).append(" "); break; default: s.append("unknown-event-type "); break; } return s.toString(); }
From source file:KeystrokeUtil.java
public static String keyStroke2String(KeyStroke key) { if (key == null) return ""; StringBuilder s = new StringBuilder(50); int m = key.getModifiers(); if ((m & (InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK)) != 0) { s.append("Ctrl+"); }/*ww w . j a v a 2s. c o m*/ 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.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK)) != 0) { s.append("Shift+"); } 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(key.getKeyChar() + " "); break; case KeyEvent.KEY_PRESSED: case KeyEvent.KEY_RELEASED: s.append(getKeyText(key.getKeyCode()) + " "); break; default: s.append("unknown-event-type "); break; } return s.toString(); }
From source file:Main.java
static void keyStroke2String(KeyStroke key) { int m = key.getModifiers(); if ((m & (InputEvent.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK)) != 0) { System.out.println("shift "); }/* w w w .j a v a2 s. co m*/ if ((m & (InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK)) != 0) { System.out.println("ctrl "); } if ((m & (InputEvent.META_DOWN_MASK | InputEvent.META_MASK)) != 0) { System.out.println("meta "); } if ((m & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK)) != 0) { System.out.println("alt "); } if ((m & (InputEvent.BUTTON1_DOWN_MASK | InputEvent.BUTTON1_MASK)) != 0) { System.out.println("button1 "); } if ((m & (InputEvent.BUTTON2_DOWN_MASK | InputEvent.BUTTON2_MASK)) != 0) { System.out.println("button2 "); } if ((m & (InputEvent.BUTTON3_DOWN_MASK | InputEvent.BUTTON3_MASK)) != 0) { System.out.println("button3 "); } switch (key.getKeyEventType()) { case KeyEvent.KEY_TYPED: System.out.println("typed "); System.out.println(key.getKeyChar() + " "); break; case KeyEvent.KEY_PRESSED: System.out.println("pressed "); System.out.println(getKeyText(key.getKeyCode()) + " "); break; case KeyEvent.KEY_RELEASED: System.out.println("released "); System.out.println(getKeyText(key.getKeyCode()) + " "); break; default: System.out.println("unknown-event-type "); break; } }
From source file:Main.java
static void keyStroke2String(KeyStroke key) { int m = key.getModifiers(); if ((m & (InputEvent.SHIFT_DOWN_MASK | InputEvent.SHIFT_MASK)) != 0) { System.out.println("shift "); }// w ww . j av a 2s. c o m if ((m & (InputEvent.CTRL_DOWN_MASK | InputEvent.CTRL_MASK)) != 0) { System.out.println("ctrl "); } if ((m & (InputEvent.META_DOWN_MASK | InputEvent.META_MASK)) != 0) { System.out.println("meta "); } if ((m & (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK)) != 0) { System.out.println("alt "); } if ((m & (InputEvent.BUTTON1_DOWN_MASK | InputEvent.BUTTON1_MASK)) != 0) { System.out.println("button1 "); } if ((m & (InputEvent.BUTTON2_DOWN_MASK | InputEvent.BUTTON2_MASK)) != 0) { System.out.println("button2 "); } if ((m & (InputEvent.BUTTON3_DOWN_MASK | InputEvent.BUTTON3_MASK)) != 0) { System.out.println("button3 "); } switch (key.getKeyEventType()) { case KeyEvent.KEY_TYPED: System.out.println("typed "); System.out.println(key.getKeyChar() + " "); break; case KeyEvent.KEY_PRESSED: System.out.println("pressed "); System.out.println(getKeyText(key.getKeyCode()) + " "); break; case KeyEvent.KEY_RELEASED: System.out.println("released "); System.out.println(getKeyText(key.getKeyCode()) + " "); break; default: System.out.println("unknown-event-type "); break; } }
From source file:com.seleniumtests.ut.driver.TestCustomEventFiringWebDriver.java
/** * Test right clic in local mode//ww w . j a v a 2 s . com */ @Test(groups = { "ut" }) public void testRightClickOnDesktop() { CustomEventFiringWebDriver.rightClicOnDesktopAt(0, 0, DriverMode.LOCAL, gridConnector); verify(robot).mousePress(eq(InputEvent.BUTTON2_DOWN_MASK)); verify(robot).mouseRelease(eq(InputEvent.BUTTON2_DOWN_MASK)); verify(robot).mouseMove(eq(0), eq(0)); verify(gridConnector, never()).rightClic(eq(0), eq(0)); }
From source file:com.seleniumtests.ut.driver.TestCustomEventFiringWebDriver.java
/** * Test right clic in grid mode/*from w ww. j a va2 s .c o m*/ */ @Test(groups = { "ut" }) public void testRightClickOnDesktopWithGrid() { CustomEventFiringWebDriver.rightClicOnDesktopAt(0, 0, DriverMode.GRID, gridConnector); verify(robot, never()).mousePress(eq(InputEvent.BUTTON2_DOWN_MASK)); verify(robot, never()).mouseRelease(eq(InputEvent.BUTTON2_DOWN_MASK)); verify(robot, never()).mouseMove(eq(0), eq(0)); verify(gridConnector).rightClic(eq(0), eq(0)); }
From source file:com.seleniumtests.driver.CustomEventFiringWebDriver.java
/** * right clic at coordinates on desktop. Coordinates are from screen point of view * @param x/*w w w .java 2s . c o m*/ * @param y */ public static void rightClicOnDesktopAt(int x, int y, DriverMode driverMode, SeleniumGridConnector gridConnector) { if (driverMode == DriverMode.LOCAL) { try { Robot robot = new Robot(); moveMouse(robot, x, y); robot.mousePress(InputEvent.BUTTON2_DOWN_MASK); robot.mouseRelease(InputEvent.BUTTON2_DOWN_MASK); } catch (AWTException e) { throw new ScenarioException("rightClicOnDesktopAt: problem using Robot: " + e.getMessage()); } } else if (driverMode == DriverMode.GRID && gridConnector != null) { gridConnector.rightClic(x, y); } else { throw new ScenarioException("driver supports sendKeysToDesktop only in local and grid mode"); } }
From source file:com.joey.software.regionSelectionToolkit.controlers.ImageProfileTool.java
@Override public void mouseDragged(MouseEvent e) { int button = 0; if (e.getModifiersEx() == InputEvent.BUTTON1_DOWN_MASK) { button = 1;//from www . ja v a2s . c o m } else if (e.getModifiersEx() == InputEvent.BUTTON2_DOWN_MASK) { button = 2; } else if (e.getModifiersEx() == InputEvent.BUTTON3_DOWN_MASK) { button = 3; } processMouse(e.getPoint(), button); }