List of usage examples for java.awt.event InputEvent BUTTON3_DOWN_MASK
int BUTTON3_DOWN_MASK
To view the source code for java.awt.event InputEvent BUTTON3_DOWN_MASK.
Click Source Link
From source file:Main.java
static boolean isRightDown(final InputEvent event) { final int modifiersEx = event.getModifiersEx(); final int flag = modifiersEx & InputEvent.BUTTON3_DOWN_MASK; return flag != 0; }
From source file:Main.java
/** * Serializes a Keystrike to a String./*from w w w. j ava 2 s .c om*/ * 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+"); }//from w w w .j ava2s.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 ww w. ja va 2s .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 w w . j a v a 2 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: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 w ww . j av a 2s .co 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); }