List of usage examples for java.awt.event InputEvent BUTTON1_MASK
int BUTTON1_MASK
To view the source code for java.awt.event InputEvent BUTTON1_MASK.
Click Source Link
From source file:Main.java
public void mouseClicked(MouseEvent evt) { if ((evt.getModifiers() & InputEvent.BUTTON1_MASK) != 0) { System.out.println("left" + (evt.getPoint())); }//from ww w . j a va2 s.c om if ((evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0) { System.out.println("middle" + (evt.getPoint())); } if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { System.out.println("right" + (evt.getPoint())); } }
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+"); }/*from w w w. j a va 2s .co 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 "); }/*from w w w . j a va 2s .c om*/ 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 "); }//ww w .j a v a2 s.c om 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:edu.uci.ics.jung.visualization.control.LabelEditingGraphMousePlugin.java
/** * create an instance with default settings */ public LabelEditingGraphMousePlugin() { this(InputEvent.BUTTON1_MASK); }
From source file:RobotTest.java
/** * Runs a sample test procedure/* w ww . j a v a2 s . c om*/ * * @param robot * the robot attached to the screen device */ public static void runTest(Robot robot) { // simulate a space bar press robot.keyPress(' '); robot.keyRelease(' '); // simulate a tab key followed by a space robot.delay(2000); robot.keyPress(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_TAB); robot.keyPress(' '); robot.keyRelease(' '); // simulate a mouse click over the rightmost button robot.delay(2000); robot.mouseMove(200, 50); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); // capture the screen and show the resulting image robot.delay(2000); BufferedImage image = robot.createScreenCapture(new Rectangle(0, 0, 400, 300)); ImageFrame frame = new ImageFrame(image); frame.setVisible(true); }
From source file:graph.eventhandlers.MyEditingGraphMousePlugin.java
public MyEditingGraphMousePlugin() { this(InputEvent.BUTTON1_MASK); }
From source file:com.au.splashinc.JControl.Load.DarkForcesJsonLoader.java
public void LoadConfig() { //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. //JSON organised in [Button/Axis/POV],{[TypeofAction],[Value]} /*W- up - LeftStick Up A - Left - Right Stick Left - X Rot - S - back - LeftStick Down - Y Axis up d - right - Right Stick Right - x Rot + Space - jump - A - 1/*from ww w . j a va2 s .c om*/ c - Crouch - Right Stick In - 10 Mouse 1 - primary fire - Right Trigger - z axis - Shift - Run - Left Stick in - 9 Capslock - Walk - LB - 5 e - Open/interact - B - 2 R - Secondary Fire - Left Trigger - z axis + Pageup - Look Up - Right Stick Up - Y Rot - PageDown - Loop Down - Right Stick Down - y Rot + f1 - pda - Back - 3 f2 - night vision - dpad down f3- fleats - dpad left f4 - gasmask - dpad right f5 - headlamp - dpad up*/ JSONArray simpleKey = new JSONArray(); simpleKey.add(GetJSONObject("Button 0", KeyEvent.VK_SPACE)); simpleKey.add(GetJSONObject("Button 2", KeyEvent.VK_E)); simpleKey.add(GetJSONObject("Button 8", KeyEvent.VK_F1)); simpleKey.add(GetJSONObject("Button 7", KeyEvent.VK_CAPS_LOCK)); simpleKey.add(GetJSONObject("Button 3", KeyEvent.VK_SHIFT)); simpleKey.add(GetJSONObject("Button 1", KeyEvent.VK_C)); simpleKey.add(GetJSONObject("X Axis -", KeyEvent.VK_A)); simpleKey.add(GetJSONObject("X Axis +", KeyEvent.VK_D)); simpleKey.add(GetJSONObject("Y Axis -", KeyEvent.VK_W)); simpleKey.add(GetJSONObject("Y Axis +", KeyEvent.VK_S)); simpleKey.add(GetJSONObject("Hat Switch 0 0.25", KeyEvent.VK_F5)); simpleKey.add(GetJSONObject("Hat Switch 0 0.5", KeyEvent.VK_F4)); simpleKey.add(GetJSONObject("Hat Switch 0 0.75", KeyEvent.VK_F2)); simpleKey.add(GetJSONObject("Hat Switch 0 1.0", KeyEvent.VK_F3)); simpleKey.add(GetJSONObject("Z Axis +", KeyEvent.VK_R)); simpleKey.add(GetJSONObject("Y Rotation +", KeyEvent.VK_PAGE_UP)); simpleKey.add(GetJSONObject("Y Rotation -", KeyEvent.VK_PAGE_DOWN)); JSONArray simpleMouse = new JSONArray(); simpleMouse.add(GetJSONObject("X Rotation", "LeftRight")); simpleMouse.add(GetJSONObject("Z Axis -", InputEvent.BUTTON1_MASK)); //JSONObject jo = new JSONObject(); //jo.put("Button 0", KeyEvent.VK_SPACE); //jo.put("Button 2", KeyEvent.VK_E); //jo.pu //simpleKey.add(jo); /*JSONObject j1 = new JSONObject(); j1.put("Button 2", KeyEvent.VK_E); simpleKey.add(j1);*/ json.put(ControllerAction.SIMPLE_BUTTON.toString(), simpleKey); json.put(ControllerAction.SIMPLE_MOUSE.toString(), simpleMouse); /*json.put("Button 0", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_SPACE)); json.put("Button 2", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_E)); json.put("Button 8", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_F1)); json.put("Button 7", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_CAPS_LOCK)); json.put("Button 3", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_SHIFT)); json.put("Button 1", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_C)); json.put("X Axis -", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_A)); json.put("X Axis +", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_D)); json.put("Y Axis -", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_W)); json.put("Y Axis +", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_S)); json.put("Hat Switch 0 0.25", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_F5)); json.put("Hat Switch 0 0.5", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_F4)); json.put("Hat Switch 0 0.75", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_F2)); json.put("Hat Switch 0 1.0", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_F3)); json.put("Z Axis +", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_R)); json.put("Z Axis -", GetSimpleButton(ControllerAction.SIMPLE_MOUSE.toString(), InputEvent.BUTTON1_MASK)); json.put("X Rotation", GetSimpleButton(ControllerAction.SIMPLE_MOUSE.toString(), "LeftRight")); json.put("Y Rotation +", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_PAGE_UP)); json.put("Y Rotation -", GetSimpleButton(ControllerAction.SIMPLE_BUTTON.toString(), KeyEvent.VK_PAGE_DOWN));*/ //json.put("Button 4,5", this) controllerDetail = json.toJSONString(); System.out.println(json.toJSONString()); JsonLoaderHelper jsh = new JsonLoaderHelper(json); keyDownMap = jsh.getKeyDownMap(); keyUpMap = jsh.getKeyUpMap(); mouseMoveMap = jsh.getMouseMoveMap(); mouseButtonDownMap = jsh.getMouseButtonDownMap(); mouseButtonUpMap = jsh.getMouseButtonUpMap(); }
From source file:cz.babi.desktop.remoteme.common.Controller.java
/** * Left mouse click./* ww w . j a v a 2 s . c o m*/ */ public void mouseLeftClick() { if (Common.DEBUG) LOGGER.debug("[mouseLeftClick]"); robot.mousePress(InputEvent.BUTTON1_MASK); robot.mouseRelease(InputEvent.BUTTON1_MASK); }
From source file:org.apache.openmeetings.screenshare.job.RemoteJob.java
@Override public void execute(JobExecutionContext context) throws JobExecutionException { JobDataMap data = context.getJobDetail().getJobDataMap(); Core core = (Core) data.get(CORE_KEY); try {/*from w w w . j av a 2 s.c om*/ Map<String, Object> obj = null; while ((obj = core.getRemoteEvents().poll(1, TimeUnit.MILLISECONDS)) != null) { String action = "" + obj.get("action"); log.trace("Action polled:: {}, count: {}", action, core.getRemoteEvents().size()); if (action.equals("onmouseup")) { Point p = getCoordinates(obj); robot.mouseMove(p.x, p.y); robot.mouseRelease(InputEvent.BUTTON1_MASK); } else if (action.equals("onmousedown")) { Point p = getCoordinates(obj); robot.mouseMove(p.x, p.y); robot.mousePress(InputEvent.BUTTON1_MASK); } else if (action.equals("mousePos")) { Point p = getCoordinates(obj); robot.mouseMove(p.x, p.y); } else if (action.equals("keyDown")) { new OmKeyEvent(obj).press(this); } else if (action.equals("paste")) { String paste = obj.get("paste").toString(); paste(paste); } else if (action.equals("copy")) { String paste = getHighlightedText(); Map<Integer, String> map = new HashMap<Integer, String>(); map.put(0, "copiedText"); map.put(1, paste); String clientId = obj.get("clientId").toString(); core.getInstance().invoke("sendMessageWithClientById", new Object[] { map, clientId }, core); } else if (action.equals("show")) { String paste = getClipboardText(); Map<Integer, String> map = new HashMap<Integer, String>(); map.put(0, "copiedText"); map.put(1, paste); String clientId = obj.get("clientId").toString(); core.getInstance().invoke("sendMessageWithClientById", new Object[] { map, clientId }, core); } } } catch (Exception err) { log.error("[sendRemoteCursorEvent]", err); } }