Java Code Examples for java.awt.event.KeyEvent#VK_PLUS

The following examples show how to use java.awt.event.KeyEvent#VK_PLUS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeyShortcut.java    From netbeans-mmd-plugin with Apache License 2.0 6 votes vote down vote up
private static int preprocessCharKeyCode(final int modifiers, char keyChar) {
  final int result;
  switch (keyChar) {
    case 0xA0: {
      // non-breakable space as space
      result = KeyEvent.VK_SPACE;
    }
    break;
    case '+': {
      // Character '+' is 0x2b but VK_PLUS is 0x0209
      result = KeyEvent.VK_PLUS;
    }
    break;
    case 0x0D: {
      // Decode CR as ENTER
      result = KeyEvent.VK_ENTER;
    }
    break;
    default: {
      result = keyChar;
    }
  }
  return result;
}
 
Example 2
Source File: TextArea.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void processKeyEvent(KeyEvent e) {
    if (e.isControlDown() && e.getID() == KeyEvent.KEY_RELEASED) {
        int keyCode = e.getKeyCode();
        if (keyCode == KeyEvent.VK_EQUALS || keyCode == KeyEvent.VK_PLUS) {
            if (changeSize(e.isShiftDown(), true)) e.consume();
        } else if (keyCode == KeyEvent.VK_MINUS) {
            if (changeSize(e.isShiftDown(), false)) e.consume();
        } else if (keyCode == KeyEvent.VK_0) {
            if (resetSize()) e.consume();
        }
    }
    
    if (!e.isConsumed()) super.processKeyEvent(e);
}
 
Example 3
Source File: GUILabelingTool.java    From Pixie with MIT License 5 votes vote down vote up
/**
 * Handling of the keyboard events when Control key is pressed.
 *
 * @param key the key code
 */
private void handleCtrlKey(int key) {
    switch (key) {
        case KeyEvent.VK_PLUS:
            log.info("Key pressed: Ctrl NumPad+ =  Zoom in");
            break;

        case KeyEvent.VK_MINUS:
            log.info("Key pressed: Ctrl NumPad- =  Zoom out");
            break;

        case KeyEvent.VK_A:
            // decrease left
            gc.changeSizeSelection(1, 0, 0, 0);
            break;

        case KeyEvent.VK_W:
            // decrease top
            gc.changeSizeSelection(0, 1, 0, 0);
            break;

        case KeyEvent.VK_D:
            // decrease right
            gc.changeSizeSelection(0, 0, -1, 0);
            break;

        case KeyEvent.VK_S:
            // decrease bottom
            gc.changeSizeSelection(0, 0, 0, -1);
            break;

        default:
            // do nothing
            break;
    }
}
 
Example 4
Source File: TextArea.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
protected void processKeyEvent(KeyEvent e) {
    if (e.isControlDown() && e.getID() == KeyEvent.KEY_RELEASED) {
        int keyCode = e.getKeyCode();
        if (keyCode == KeyEvent.VK_EQUALS || keyCode == KeyEvent.VK_PLUS) {
            if (changeSize(e.isShiftDown(), true)) e.consume();
        } else if (keyCode == KeyEvent.VK_MINUS) {
            if (changeSize(e.isShiftDown(), false)) e.consume();
        } else if (keyCode == KeyEvent.VK_0) {
            if (resetSize()) e.consume();
        }
    }
    
    if (!e.isConsumed()) super.processKeyEvent(e);
}
 
Example 5
Source File: KeyCodeToChar.java    From Repeat with Apache License 2.0 5 votes vote down vote up
private static String getCharFromNumpadCode(int code, KeyboardState state) {
	if (!state.isNumslockLocked()) {
		return "";
	}

	switch (code) {
		case KeyEvent.VK_NUMPAD0:
			return "0";
		case KeyEvent.VK_NUMPAD1:
			return "1";
		case KeyEvent.VK_NUMPAD2:
			return "2";
		case KeyEvent.VK_NUMPAD3:
			return "3";
		case KeyEvent.VK_NUMPAD4:
			return "4";
		case KeyEvent.VK_NUMPAD5:
			return "5";
		case KeyEvent.VK_NUMPAD6:
			return "6";
		case KeyEvent.VK_NUMPAD7:
			return "7";
		case KeyEvent.VK_NUMPAD8:
			return "8";
		case KeyEvent.VK_NUMPAD9:
			return "9";
		case KeyEvent.VK_PLUS:
			return "+";
		case KeyEvent.VK_MULTIPLY:
			return "*";
		default:
			return "";
	}
}
 
Example 6
Source File: ToolTipAction.java    From Digital with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Sets an accelerator to the action
 *
 * @param accelerator the accelerator
 * @return this for call chaining
 */
public ToolTipAction setAccelerator(KeyStroke accelerator) {
    if (accelerator.getKeyCode() == KeyEvent.VK_PLUS && Settings.getInstance().get(Keys.SETTINGS_USE_EQUALS_KEY))
        accelerator = KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, accelerator.getModifiers());
    this.accelerator = accelerator;
    return this;
}
 
Example 7
Source File: PhotoEditorPanel.java    From mvisc with GNU General Public License v3.0 4 votes vote down vote up
public void keyReleased(KeyEvent e)
		{
			
			copyMade = false;
			if (e.getKeyCode() == KeyEvent.VK_SPACE)
			{
//				System.out.println("k:"+selected);

				selected = !selected;
				System.out.println("hit space" + selected);
				unsavedChange = true;
				repaint();
			}
			if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
			{
				selected = false;
				repaint();
			}
			if (e.getKeyCode() == KeyEvent.VK_SHIFT)
			{
				shiftDown = false;
			}
			if (e.getKeyCode() == KeyEvent.VK_CONTROL)
			{
				controlDown = false;
			}
			if ((e.getKeyCode() == KeyEvent.VK_PLUS) || (e.getKeyCode() == KeyEvent.VK_ADD))
			{
				contrast++;
				repaint();
				copyMade = false;
			}
			if ((e.getKeyCode() == KeyEvent.VK_MINUS) || (e.getKeyCode() == KeyEvent.VK_SUBTRACT))
			{
				contrast--;
				repaint();
				copyMade = false;
			}
			if (e.getKeyCode() == KeyEvent.VK_MULTIPLY)
			{
				blur = !blur;
				repaint();
				copyMade = false;
			}

		}
 
Example 8
Source File: ActionUtils.java    From workcraft with MIT License 4 votes vote down vote up
public static String getKeyString(int keyCode) {
    // Letters and numbers
    if (((keyCode >= KeyEvent.VK_0) && (keyCode <= KeyEvent.VK_9))
            || ((keyCode >= KeyEvent.VK_A) && (keyCode <= KeyEvent.VK_Z))) {
        return String.valueOf((char) keyCode);
    }
    switch (keyCode) {
    // Navigation keys
    case KeyEvent.VK_LEFT: return "Left";
    case KeyEvent.VK_UP: return "Up";
    case KeyEvent.VK_RIGHT: return "Right";
    case KeyEvent.VK_DOWN: return "Down";
    // Extra navigation keys
    case KeyEvent.VK_INSERT: return "Insert";
    case KeyEvent.VK_DELETE: return "Delete";
    case KeyEvent.VK_END: return "End";
    case KeyEvent.VK_HOME: return "Home";
    case KeyEvent.VK_PAGE_UP: return "PgUp";
    case KeyEvent.VK_PAGE_DOWN: return "PgDn";
    // Function keys
    case KeyEvent.VK_F1: return "F1";
    case KeyEvent.VK_F2: return "F2";
    case KeyEvent.VK_F3: return "F3";
    case KeyEvent.VK_F4: return "F4";
    case KeyEvent.VK_F5: return "F5";
    case KeyEvent.VK_F6: return "F6";
    case KeyEvent.VK_F7: return "F7";
    case KeyEvent.VK_F8: return "F8";
    case KeyEvent.VK_F9: return "F9";
    case KeyEvent.VK_F10: return "F10";
    case KeyEvent.VK_F11: return "F11";
    case KeyEvent.VK_F12: return "F12";
    // Symbols
    case KeyEvent.VK_EXCLAMATION_MARK: return "!";
    case KeyEvent.VK_QUOTEDBL: return "\"";
    case KeyEvent.VK_EURO_SIGN: return "€";
    case KeyEvent.VK_DOLLAR: return "$";
    case KeyEvent.VK_CIRCUMFLEX: return "^";
    case KeyEvent.VK_AMPERSAND: return "&";
    case KeyEvent.VK_ASTERISK: return "*";
    case KeyEvent.VK_UNDERSCORE: return "_";
    case KeyEvent.VK_MINUS: return "-";
    case KeyEvent.VK_PLUS: return "+";
    case KeyEvent.VK_EQUALS: return "=";
    case KeyEvent.VK_AT: return "@";
    case KeyEvent.VK_NUMBER_SIGN: return "#";
    case KeyEvent.VK_COLON: return ":";
    case KeyEvent.VK_SEMICOLON: return ";";
    case KeyEvent.VK_COMMA: return ",";
    case KeyEvent.VK_PERIOD: return ".";
    case KeyEvent.VK_SLASH: return "/";
    case KeyEvent.VK_BACK_SLASH: return "\\";
    case KeyEvent.VK_DEAD_TILDE: return "~";
    // Parenthesis and brackets
    case KeyEvent.VK_LEFT_PARENTHESIS: return "(";
    case KeyEvent.VK_RIGHT_PARENTHESIS: return ")";
    case KeyEvent.VK_OPEN_BRACKET: return "[";
    case KeyEvent.VK_CLOSE_BRACKET: return "]";
    case KeyEvent.VK_BRACELEFT: return "{";
    case KeyEvent.VK_BRACERIGHT: return "}";
    case KeyEvent.VK_LESS: return "<";
    case KeyEvent.VK_GREATER: return ">";
    // Formatting keys
    case KeyEvent.VK_SPACE: return "Space";
    case KeyEvent.VK_TAB: return "Tab";
    case KeyEvent.VK_ENTER: return "Enter";
    case KeyEvent.VK_BACK_SPACE: return "Backspace";
    case KeyEvent.VK_ESCAPE: return "Esc";
    }
    return "0x" + Integer.toString(keyCode, 16);
}
 
Example 9
Source File: GraphEditorPanelKeyListener.java    From workcraft with MIT License 4 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
    if (DesktopApi.isMenuKeyDown(e)) {
        switch (e.getKeyCode()) {
        case KeyEvent.VK_LEFT:
            editor.panLeft();
            break;
        case KeyEvent.VK_UP:
            editor.panUp();
            break;
        case KeyEvent.VK_RIGHT:
            editor.panRight();
            break;
        case KeyEvent.VK_DOWN:
            editor.panDown();
            break;
        case KeyEvent.VK_TAB:
            MainWindow mainWindow = Framework.getInstance().getMainWindow();
            DockableWindow editorWindow = mainWindow.getEditorWindow(editor);
            DockingUtils.activateNextTab(editorWindow, e.isShiftDown() ? -1 : 1);
            break;
        }
    } else {
        switch (e.getKeyCode()) {
        case KeyEvent.VK_EQUALS:
        case KeyEvent.VK_PLUS:
        case KeyEvent.VK_ADD:
            editor.zoomIn();
            break;
        case KeyEvent.VK_MINUS:
        case KeyEvent.VK_UNDERSCORE:
        case KeyEvent.VK_SUBTRACT:
            editor.zoomOut();
            break;
        case KeyEvent.VK_MULTIPLY:
            editor.zoomFit();
            break;
        case KeyEvent.VK_DIVIDE:
            editor.panCenter();
            break;
        }
    }
    GraphEditorKeyEvent geke = new GraphEditorKeyEvent(editor, e);
    forwardListener.keyPressed(geke);
}
 
Example 10
Source File: Catbert.java    From sagetv with Apache License 2.0 4 votes vote down vote up
public static int[] getKeystrokeFromString(String s)
{
  if (s == null || s.length() == 0)
    return new int[] { 0, 0 };
  if ("+".equals(s))
    return new int[] { KeyEvent.VK_PLUS, 0 };
  int code = 0;
  int mods = 0;
  if (s.endsWith("+"))
  {
    code = KeyEvent.VK_PLUS;
    s = s.substring(0, s.length() - 1);
  }
  else
  {
    int lastPlus = s.lastIndexOf('+');
    String codestr;
    if (lastPlus != -1)
    {
      codestr = s.substring(lastPlus + 1);
      s = s.substring(0, lastPlus);
    }
    else
    {
      codestr = s;
      s = "";
    }
    Integer o = keystrokeNameMap.get(codestr);
    if (o != null)
    {
      code = o.intValue();
    }
    else
    {
      code = codestr.toUpperCase().charAt(0);
    }
  }
  String ctrlName = KeyEvent.getKeyModifiersText(KeyEvent.CTRL_MASK);
  String altName = KeyEvent.getKeyModifiersText(KeyEvent.ALT_MASK);
  String shiftName = KeyEvent.getKeyModifiersText(KeyEvent.SHIFT_MASK);
  String metaName = KeyEvent.getKeyModifiersText(KeyEvent.META_MASK);
  StringTokenizer toker = new StringTokenizer(s, "+");
  while (toker.hasMoreTokens())
  {
    String modName = toker.nextToken();
    if (modName.equalsIgnoreCase(ctrlName))
      mods = mods | KeyEvent.CTRL_MASK;
    else if (modName.equalsIgnoreCase(altName))
      mods = mods | KeyEvent.ALT_MASK;
    else if (modName.equalsIgnoreCase(shiftName))
      mods = mods | KeyEvent.SHIFT_MASK;
    else if (modName.equalsIgnoreCase(metaName))
      mods = mods | KeyEvent.META_MASK;
  }
  return new int[] { code, mods };
}
 
Example 11
Source File: GOSwingEventConverter.java    From settlers-remake with MIT License 4 votes vote down vote up
private String getKeyName(KeyEvent e) {
	String text = KeyEvent.getKeyText(e.getKeyCode());
	if (text == null || text.length() != 1) {
		switch (e.getKeyCode()) {
		case KeyEvent.VK_LEFT:
			text = "LEFT";
			break;
		case KeyEvent.VK_RIGHT:
			text = "RIGHT";
			break;
		case KeyEvent.VK_DOWN:
			text = "DOWN";
			break;
		case KeyEvent.VK_UP:
			text = "UP";
			break;
		case KeyEvent.VK_PAUSE:
			text = "PAUSE";
			break;
		case KeyEvent.VK_F1:
			text = "F1";
			break;
		case KeyEvent.VK_F2:
			text = "F2";
			break;
		case KeyEvent.VK_F3:
			text = "F3";
			break;
		case KeyEvent.VK_F4:
			text = "F4";
			break;
		case KeyEvent.VK_F5:
			text = "F5";
			break;
		case KeyEvent.VK_F6:
			text = "F6";
			break;
		case KeyEvent.VK_F7:
			text = "F7";
			break;
		case KeyEvent.VK_F8:
			text = "F8";
			break;
		case KeyEvent.VK_F9:
			text = "F9";
			break;
		case KeyEvent.VK_F10:
			text = "F10";
			break;
		case KeyEvent.VK_F11:
			text = "F11";
			break;
		case KeyEvent.VK_F12:
			text = "F12";
			break;
		case KeyEvent.VK_PLUS:
			text = "+";
			break;
		case KeyEvent.VK_MINUS:
			text = "-";
			break;
		case KeyEvent.VK_DELETE:
			text = "DELETE";
			break;
		case KeyEvent.VK_SPACE:
			text = " ";
			break;
		case KeyEvent.VK_ESCAPE:
			text = "ESCAPE";
			break;
		case KeyEvent.VK_BACK_SPACE:
			text = "BACK_SPACE";
			break;
		case KeyEvent.VK_TAB:
			text = "TAB";
			break;
		default:
			text = "" + e.getKeyChar();
		}
	}
	return text;
}
 
Example 12
Source File: MacKeymapUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static String getKeyText(int code) {
  switch (code) {
    case KeyEvent.VK_BACK_SPACE:     return BACKSPACE;
    case KeyEvent.VK_ESCAPE:         return ESCAPE;
    case KeyEvent.VK_CAPS_LOCK:      return CAPS_LOCK;
    case KeyEvent.VK_TAB:            return TAB;
    case KeyEvent.VK_SPACE:          return SPACE;
    case KeyEvent.VK_DELETE:         return DELETE;
    case KeyEvent.VK_HOME:           return HOME;
    case KeyEvent.VK_END:            return END;
    case KeyEvent.VK_PAGE_UP:        return PAGE_UP;
    case KeyEvent.VK_PAGE_DOWN:      return PAGE_DOWN;
    case KeyEvent.VK_UP:             return UP;
    case KeyEvent.VK_DOWN:           return DOWN;
    case KeyEvent.VK_LEFT:           return LEFT;
    case KeyEvent.VK_RIGHT:          return RIGHT;
    case KeyEvent.VK_NUM_LOCK:       return NUMBER_LOCK;
    case KeyEvent.VK_ENTER:          return RETURN;
    case KeyEvent.VK_BACK_QUOTE:     return "`";
    case KeyEvent.VK_NUMBER_SIGN:    return NUM_PAD;
    case KeyEvent.VK_MULTIPLY:       return NUM_PAD + " *";
    case KeyEvent.VK_ADD:            return "+";
    case KeyEvent.VK_SEPARATOR:      return ",";
    case KeyEvent.VK_SUBTRACT:       return "-";
    case KeyEvent.VK_DECIMAL:        return ".";
    case KeyEvent.VK_DIVIDE:         return "/";
    case KeyEvent.VK_NUMPAD0:        return "0";
    case KeyEvent.VK_NUMPAD1:        return "1";
    case KeyEvent.VK_NUMPAD2:        return "2";
    case KeyEvent.VK_NUMPAD3:        return "3";
    case KeyEvent.VK_NUMPAD4:        return "4";
    case KeyEvent.VK_NUMPAD5:        return "5";
    case KeyEvent.VK_NUMPAD6:        return "6";
    case KeyEvent.VK_NUMPAD7:        return "7";
    case KeyEvent.VK_NUMPAD8:        return "8";
    case KeyEvent.VK_NUMPAD9:        return "9";
    case KeyEvent.VK_SLASH:          return "/";
    case KeyEvent.VK_BACK_SLASH:     return "\\";
    case KeyEvent.VK_PERIOD:         return ".";
    case KeyEvent.VK_SEMICOLON:      return ";";
    case KeyEvent.VK_CLOSE_BRACKET:  return "]";
    case KeyEvent.VK_OPEN_BRACKET:   return "[";
    case KeyEvent.VK_EQUALS:         return "=";
    case KeyEvent.VK_MINUS:          return "-";
    case KeyEvent.VK_PLUS:           return "+";
    case 0:                          return "fn";
  }
  return KeyEvent.getKeyText(code);
}
 
Example 13
Source File: ZoomInAction.java    From PIPE with MIT License 2 votes vote down vote up
/**
 *
 * @param zoomManager Pipe zoom manager
 */
public ZoomInAction(ZoomManager zoomManager) {
    super("Zoom in", "Zoom in by 10% ", KeyEvent.VK_PLUS, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask());
}