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

The following examples show how to use java.awt.event.KeyEvent#VK_9 . 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: CalculadoraTela.java    From dctb-utfpr-2018-1 with Apache License 2.0 6 votes vote down vote up
public void operarComTeclaDigitada(java.awt.event.KeyEvent evt) {
    // Se foi digitado uma das teclas a seguir
    if ((evt.getKeyCode() == KeyEvent.VK_0)
            || (evt.getKeyCode() == KeyEvent.VK_1)
            || (evt.getKeyCode() == KeyEvent.VK_2)
            || (evt.getKeyCode() == KeyEvent.VK_3)
            || (evt.getKeyCode() == KeyEvent.VK_4)
            || (evt.getKeyCode() == KeyEvent.VK_5)
            || (evt.getKeyCode() == KeyEvent.VK_6)
            || (evt.getKeyCode() == KeyEvent.VK_7)
            || (evt.getKeyCode() == KeyEvent.VK_8)
            || (evt.getKeyCode() == KeyEvent.VK_9)
            || (evt.getKeyCode() == KeyEvent.VK_ADD)
            || (evt.getKeyCode() == KeyEvent.VK_SUBTRACT)
            || (evt.getKeyCode() == KeyEvent.VK_DIVIDE)
            || (evt.getKeyCode() == KeyEvent.VK_MULTIPLY)
            || (evt.getKeyCode() == KeyEvent.VK_EQUALS)) {

        this.operarConformeEstado("" + evt.getKeyChar());

    } else if (evt.getKeyCode() == KeyEvent.VK_L) {
        this.operarConformeEstado("Limpar");
    }
}
 
Example 2
Source File: BookmarkKeyChooser.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void keyPressed(KeyEvent e) {
    int keyCode = e.getKeyCode();
    char ch = 0;
    if (KeyEvent.VK_0 <= keyCode && keyCode <= KeyEvent.VK_9) {
        ch = (char) ((keyCode - KeyEvent.VK_0) + '0');
    } else if (KeyEvent.VK_A <= keyCode && keyCode <= KeyEvent.VK_Z) {
        ch = (char) ((keyCode - KeyEvent.VK_A) + 'A');
    }
    if (ch != 0) {
        BookmarkInfo bookmark = key2bookmark.get(ch);
        if (bookmark != null) {
            result = bookmark;
            dispose();
        }
    }
}
 
Example 3
Source File: MainFrame.java    From uima-uimaj with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the mnemonic.
 *
 * @param i the i
 * @return the mnemonic
 */
private static final int getMnemonic(int i) {
  switch (i) {
  case 1:
    return KeyEvent.VK_1;
  case 2:
    return KeyEvent.VK_2;
  case 3:
    return KeyEvent.VK_3;
  case 4:
    return KeyEvent.VK_4;
  case 5:
    return KeyEvent.VK_5;
  case 6:
    return KeyEvent.VK_6;
  case 7:
    return KeyEvent.VK_7;
  case 8:
    return KeyEvent.VK_8;
  case 9:
    return KeyEvent.VK_9;
  default:
    return KeyEvent.VK_0;
  }
}
 
Example 4
Source File: ActivateToolWindowAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * @return mnemonic for action if it has Alt+digit/Meta+digit shortcut.
 * Otherwise the method returns <code>-1</code>. Meta mask is OK for
 * Mac OS X user, because Alt+digit types strange characters into the
 * editor.
 */
public static int getMnemonicForToolWindow(String id) {
  Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap();
  Shortcut[] shortcuts = activeKeymap.getShortcuts(getActionIdForToolWindow(id));
  for (Shortcut shortcut : shortcuts) {
    if (shortcut instanceof KeyboardShortcut) {
      KeyStroke keyStroke = ((KeyboardShortcut)shortcut).getFirstKeyStroke();
      int modifiers = keyStroke.getModifiers();
      if (modifiers == (InputEvent.ALT_DOWN_MASK | InputEvent.ALT_MASK) ||
          modifiers == InputEvent.ALT_MASK ||
          modifiers == InputEvent.ALT_DOWN_MASK ||
          modifiers == (InputEvent.META_DOWN_MASK | InputEvent.META_MASK) ||
          modifiers == InputEvent.META_MASK ||
          modifiers == InputEvent.META_DOWN_MASK) {
        int keyCode = keyStroke.getKeyCode();
        if (KeyEvent.VK_0 <= keyCode && keyCode <= KeyEvent.VK_9) {
          char c = (char)('0' + keyCode - KeyEvent.VK_0);
          return (int)c;
        }
      }
    }
  }
  return -1;
}
 
Example 5
Source File: JMenuItemRecentFile.java    From portecle with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the menu item's position in its recent file list (maintained by JMenuRecentFiles).
 *
 * @param iPosition Position
 */
void setPosition(int iPosition)
{
	m_iPosition = iPosition;
	setText(m_iPosition + " " + m_fRecentFile.getName());

	switch (m_iPosition)
	{
		case 1:
			super.setMnemonic(KeyEvent.VK_1);
			break;
		case 2:
			super.setMnemonic(KeyEvent.VK_2);
			break;
		case 3:
			super.setMnemonic(KeyEvent.VK_3);
			break;
		case 4:
			super.setMnemonic(KeyEvent.VK_4);
			break;
		case 5:
			super.setMnemonic(KeyEvent.VK_5);
			break;
		case 6:
			super.setMnemonic(KeyEvent.VK_6);
			break;
		case 7:
			super.setMnemonic(KeyEvent.VK_7);
			break;
		case 8:
			super.setMnemonic(KeyEvent.VK_8);
			break;
		case 9:
			super.setMnemonic(KeyEvent.VK_9);
			break;
	}
}
 
Example 6
Source File: NumberDocumentFilter.java    From WIFIADB with Apache License 2.0 5 votes vote down vote up
@Override
public void keyTyped(KeyEvent e) {
    final int key = e.getKeyChar();

    if(key < KeyEvent.VK_0 || key > KeyEvent.VK_9){
        e.consume();
    }
}
 
Example 7
Source File: KeyRemappingConfig.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@ConfigItem(
	position = 15,
	keyName = "f9",
	name = "F9",
	description = "The key which will replace {F9}."
)
default ModifierlessKeybind f9()
{
	return new ModifierlessKeybind(KeyEvent.VK_9, 0);
}
 
Example 8
Source File: KeyRemappingConfig.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@ConfigItem(
	position = 15,
	keyName = "f9",
	name = "F9",
	description = "The key which will replace {F9}.",
	section = fKeySection
)
default ModifierlessKeybind f9()
{
	return new ModifierlessKeybind(KeyEvent.VK_9, 0);
}
 
Example 9
Source File: SmoothMoves.java    From filthy-rich-clients with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Toggles various rendering flags
 */
public void keyPressed(KeyEvent ke) {
    int keyCode = ke.getKeyCode();
    if (keyCode == KeyEvent.VK_B) {
        // B: Motion blur - displays trail of ghost images
        motionBlur = !motionBlur;
    } else if (keyCode == KeyEvent.VK_A) {
        // A: Antialiasing - Displays soft edges around graphics
        useAA = !useAA;
        createAnimationImage();
    } else if (keyCode == KeyEvent.VK_C) {
        // C: Color - Toggles rectangle color between dark and light colors
        alterColor = !alterColor;
        createAnimationImage();
    } else if (keyCode == KeyEvent.VK_I) {
        // I: Image - Toggles use of image or filled rectangle to show how 
        // straight edges affect animation perception
        useImage = !useImage;
        createAnimationImage();
    } else if (keyCode == KeyEvent.VK_UP) {
        // Up Arrow: Speed - Speeds up frame rate
        changeResolution(true);
    } else if (keyCode == KeyEvent.VK_DOWN) {
        // Down Arrow: Speed - Slows down frame rate
        changeResolution(false);
    } else if (keyCode == KeyEvent.VK_L) {
        // L: Linearity: Toggles linear/nonlinear motion
        linear = !linear;
    } else if (keyCode >= KeyEvent.VK_1 && keyCode <= KeyEvent.VK_9) {
        // 0-9: Blur size: Toggles size of ghost trail for motion blur
        blurSize = keyCode - KeyEvent.VK_0;
        prevMoveX = prevMoveY = null;
    }
}
 
Example 10
Source File: KeyCodeToChar.java    From Repeat with Apache License 2.0 4 votes vote down vote up
private static String getNonAlphaCharWithoutShift(int code) {
	switch (code) {
	case KeyEvent.VK_BACK_QUOTE:
		return "`";
	case KeyEvent.VK_1:
		return "1";
	case KeyEvent.VK_2:
		return "2";
	case KeyEvent.VK_3:
		return "3";
	case KeyEvent.VK_4:
		return "4";
	case KeyEvent.VK_5:
		return "5";
	case KeyEvent.VK_6:
		return "6";
	case KeyEvent.VK_7:
		return "7";
	case KeyEvent.VK_8:
		return "8";
	case KeyEvent.VK_9:
		return "9";
	case KeyEvent.VK_0:
		return "0";
	case KeyEvent.VK_MINUS:
		return "-";
	case KeyEvent.VK_EQUALS:
		return "=";
	case KeyEvent.VK_OPEN_BRACKET:
		return "[";
	case KeyEvent.VK_CLOSE_BRACKET:
		return "]";
	case KeyEvent.VK_SEMICOLON:
		return ";";
	case KeyEvent.VK_QUOTE:
		return "'";
	case KeyEvent.VK_BACK_SLASH:
		return "\\";
	case KeyEvent.VK_COMMA:
		return ",";
	case KeyEvent.VK_PERIOD:
		return ".";
	case KeyEvent.VK_SLASH:
		return "/";
	case KeyEvent.VK_TAB:
		return "\t";
	case KeyEvent.VK_ENTER:
		return "\n";
	case KeyEvent.VK_SPACE:
		return " ";
	default:
		return "";
	}
}
 
Example 11
Source File: ProjectTree.java    From TrakEM2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void keyPressed(final KeyEvent ke) {
	super.keyPressed(ke);
	if (ke.isConsumed()) return;
	if (!ke.getSource().equals(ProjectTree.this) || !project.isInputEnabled()) {
		return;
	}
	// get the first selected node only
	TreePath path = getSelectionPath();
	if (null == path) return;
	DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
	if (null == node) return;
	final ProjectThing pt = (ProjectThing)node.getUserObject();
	if (null == pt) return;
	//
	final int flags = ke.getModifiers();
	switch (ke.getKeyCode()) {
		case KeyEvent.VK_PAGE_UP:
			move(node, -1);
			ke.consume(); // in any case
			break;
		case KeyEvent.VK_PAGE_DOWN:
			move(node, 1);
			ke.consume(); // in any case
			break;
		case KeyEvent.VK_F2:
			rename(pt);
			ke.consume();
			break;
		case KeyEvent.VK_H:
			if (0 == (flags ^ Event.ALT_MASK)) {
				pt.setVisible(true);
				ke.consume();
			} else if (0 == flags) {
				pt.setVisible(false);
				ke.consume();
			}
			break;
		case KeyEvent.VK_A:
			if (0 == flags || (0 == (flags ^ Event.SHIFT_MASK))) {
				selectInDisplay(pt, 0 == (flags ^ Event.SHIFT_MASK));
				ke.consume();
			}
			break;
		case KeyEvent.VK_3:
			if (0 == flags) {
				ini.trakem2.display.Display3D.showAndResetView(pt);
				ke.consume();
				break;
			}
			// else, flow:
		case KeyEvent.VK_1:
		case KeyEvent.VK_2:
		case KeyEvent.VK_4:
		case KeyEvent.VK_5:
		case KeyEvent.VK_6:
		case KeyEvent.VK_7:
		case KeyEvent.VK_8:
		case KeyEvent.VK_9:
			// run a plugin, if any
			if (pt.getObject() instanceof Displayable && null != Utils.launchTPlugIn(ke, "Project Tree", project, (Displayable)pt.getObject())) {
				ke.consume();
			}
			break;
	}
	ke.consume();
}
 
Example 12
Source File: Spectrum.java    From wandora with GNU General Public License v3.0 4 votes vote down vote up
private int key(KeyEvent e) {
    int c = e.getKeyCode();
    int a = e.getKeyChar();
    int i = "[AQ10P\n ZSW29OL]XDE38IKMCFR47UJNVGT56YHB".indexOf((char) c);
    if (i >= 0) {
        simple:
        {
            int s = 0;
            if (c >= KeyEvent.VK_0 && c <= KeyEvent.VK_9) {
                if (c != (int) a) {
                    break simple;
                }
                if (e.isAltDown()) {
                    s = 0100;
                }
            }
            return i | s;
        }
    }
    if (a != '\0') {
        i = "\t\0\0!_\"\0\0:\0\0@);=\0\0\0\0#(\0+.?\0<$'\0-,/\0>%&\0^*".indexOf(a);
        if (i >= 0) {
            return i | 0200;
        }
    }
    switch (c) {
        case KeyEvent.VK_INSERT:
        case KeyEvent.VK_ESCAPE:
            return 0103;
        case KeyEvent.VK_KP_LEFT:
        case KeyEvent.VK_LEFT:
            i = 0;
            break;
        case KeyEvent.VK_KP_DOWN:
        case KeyEvent.VK_DOWN:
            i = 3;
            break;
        case KeyEvent.VK_KP_UP:
        case KeyEvent.VK_UP:
            i = 2;
            break;
        case KeyEvent.VK_KP_RIGHT:
        case KeyEvent.VK_RIGHT:
            i = 1;
            break;
        case KeyEvent.VK_BACK_SPACE:
            return 0104;
        case KeyEvent.VK_SHIFT:
            return 01000;
        case KeyEvent.VK_CONTROL:
            kempston |= 0x10; /* fall */

        case KeyEvent.VK_ALT:
            return 02000;
        default:
            return -1;
    }
    kempston |= 1 << (i ^ 1);
    return e.isAltDown() ? arrowsDefault[i] : arrows[i];
}
 
Example 13
Source File: GameKeyHandler.java    From stendhal with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void keyPressed(final KeyEvent e) {
	final int keyCode = e.getKeyCode();
	final boolean doublePress = isDoublePress(keyCode);

	/* Ignore if the key is already pressed down. */
	if (!client.keyIsPressed(keyCode)) {
		/* Add keyCode to pressedStateKeys list. */
		client.onKeyPressed(keyCode);

		if (e.isShiftDown()) {
			/*
			 * We are going to use shift to move to previous/next line of text
			 * with arrows so we just ignore the keys if shift is pressed.
			 */
			return;
		}

		switch (keyCode) {
		case KeyEvent.VK_R:
			if (e.isControlDown()) {
				/*
				 * Ctrl+R Remove text bubbles
				 */
				screen.clearTexts();
			}
			break;

		case KeyEvent.VK_LEFT:
		case KeyEvent.VK_RIGHT:
		case KeyEvent.VK_UP:
		case KeyEvent.VK_DOWN:
		case KeyEvent.VK_KP_LEFT:
		case KeyEvent.VK_KP_RIGHT:
		case KeyEvent.VK_KP_UP:
		case KeyEvent.VK_KP_DOWN:
			/*
			 * Ctrl means face, otherwise move. Alt turns on auto-walk.
			 */
			final Direction direction = keyCodeToDirection(e.getKeyCode());

			/* Check if the player is currently using auto-walk or the Alt
			 * key is pressed.
			 */
			User user = User.get();
			if ((user.getRPObject().has(AUTOWALK) ||
					("true".equals(WtWindowManager.getInstance().getProperty(DOUBLE_TAP_AUTOWALK_PROPERTY, "false"))
					&& doublePress))) {
				/* Face direction pressed and toggle auto-walk. */
				this.processAutoWalk(direction, user);
			} else {
				if (e.isAltGraphDown()) {
					if (System.currentTimeMillis() - lastAction > 1000) {
						final EntityView<?> view = screen.getEntityViewAt(
								user.getX()
										+ direction.getdx(), user.getY()
										+ direction.getdy());

						if (view != null) {
							final IEntity entity = view.getEntity();
							if (!entity.equals(user)) {
								view.onAction();
								lastAction = System.currentTimeMillis();
							}
						}
					}
				}

				this.processDirectionPress(direction, e.isControlDown());
			}
			break;
		case KeyEvent.VK_0:
		case KeyEvent.VK_1:
		case KeyEvent.VK_2:
		case KeyEvent.VK_3:
		case KeyEvent.VK_4:
		case KeyEvent.VK_5:
		case KeyEvent.VK_6:
		case KeyEvent.VK_7:
		case KeyEvent.VK_8:
		case KeyEvent.VK_9:
			switchToSpellCastingState(e);
			break;
		}
	}
}
 
Example 14
Source File: KeyCodeToChar.java    From Repeat with Apache License 2.0 4 votes vote down vote up
private static String getNonAlphaCharWithShift(int code) {
	switch (code) {
	case KeyEvent.VK_BACK_QUOTE:
		return "~";
	case KeyEvent.VK_1:
		return "!";
	case KeyEvent.VK_2:
		return "@";
	case KeyEvent.VK_3:
		return "#";
	case KeyEvent.VK_4:
		return "$";
	case KeyEvent.VK_5:
		return "%";
	case KeyEvent.VK_6:
		return "^";
	case KeyEvent.VK_7:
		return "&";
	case KeyEvent.VK_8:
		return "*";
	case KeyEvent.VK_9:
		return "(";
	case KeyEvent.VK_0:
		return ")";
	case KeyEvent.VK_MINUS:
		return "_";
	case KeyEvent.VK_EQUALS:
		return "+";
	case KeyEvent.VK_OPEN_BRACKET:
		return "{";
	case KeyEvent.VK_CLOSE_BRACKET:
		return "}";
	case KeyEvent.VK_SEMICOLON:
		return ":";
	case KeyEvent.VK_QUOTE:
		return "\"";
	case KeyEvent.VK_BACK_SLASH:
		return "|";
	case KeyEvent.VK_COMMA:
		return "<";
	case KeyEvent.VK_PERIOD:
		return ">";
	case KeyEvent.VK_SLASH:
		return "?";
	case KeyEvent.VK_TAB:
		return "\t";
	case KeyEvent.VK_ENTER:
		return "\n";
	case KeyEvent.VK_SPACE:
		return " ";
	default:
		return "";
	}
}
 
Example 15
Source File: Robot.java    From xnx3 with Apache License 2.0 4 votes vote down vote up
/**
 * 将字符型转换为按键码,可直接使用 {@link #press(int)}调用
 * @param key 字符型文字,包含 0~9 a~z .
 * @return 按键码
 */
public int StringToKey(String key){
	switch (key) {
	case "a":
		return KeyEvent.VK_A;
	case "b":
		return KeyEvent.VK_B;
	case "c":
		return KeyEvent.VK_C;
	case "d":
		return KeyEvent.VK_D;
	case "e":
		return KeyEvent.VK_E;
	case "f":
		return KeyEvent.VK_F;
	case "g":
		return KeyEvent.VK_G;
	case "h":
		return KeyEvent.VK_H;
	case "i":
		return KeyEvent.VK_I;
	case "j":
		return KeyEvent.VK_J;
	case "k":
		return KeyEvent.VK_K;
	case "l":
		return KeyEvent.VK_L;
	case "m":
		return KeyEvent.VK_M;
	case "n":
		return KeyEvent.VK_N;
	case "o":
		return KeyEvent.VK_O;
	case "p":
		return KeyEvent.VK_P;
	case "q":
		return KeyEvent.VK_Q;
	case "r":
		return KeyEvent.VK_R;
	case "s":
		return KeyEvent.VK_S;
	case "t":
		return KeyEvent.VK_T;
	case "u":
		return KeyEvent.VK_U;
	case "v":
		return KeyEvent.VK_V;
	case "w":
		return KeyEvent.VK_W;
	case "x":
		return KeyEvent.VK_X;
	case "y":
		return KeyEvent.VK_Y;
	case "z":
		return KeyEvent.VK_Z;
	case "0":
		return KeyEvent.VK_0;
	case "1":
		return KeyEvent.VK_1;
	case "2":
		return KeyEvent.VK_2;
	case "3":
		return KeyEvent.VK_3;
	case "4":
		return KeyEvent.VK_4;
	case "5":
		return KeyEvent.VK_5;
	case "6":
		return KeyEvent.VK_6;
	case "7":
		return KeyEvent.VK_7;
	case "8":
		return KeyEvent.VK_8;
	case "9":
		return KeyEvent.VK_9;
	case ".":
		return KeyEvent.VK_PERIOD;
	default:
		break;
	}
	
	return 0;
}
 
Example 16
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 17
Source File: MITextEditorPane.java    From MeteoInfo with GNU Lesser General Public License v3.0 4 votes vote down vote up
private synchronized void type(KeyEvent e) {
    if (this.popup.isVisible()) {
        if (e.getID() == KeyEvent.KEY_PRESSED) {
            this.popup.type(e);
        }
        return;
    }

    switch (e.getKeyCode()) {
        case (KeyEvent.VK_PERIOD):
            showPopup();
            e.consume();
            break;
        case (KeyEvent.VK_SPACE):
            String command = getCurrentText();
            Matcher match = FROM_PACKAGE_IMPORT.matcher(command);
            if (match.matches()) {
                showPopup();
            }
            e.consume();
            break;
        case (KeyEvent.VK_9):
            if (e.isShiftDown()) {
                showTip();
            }
            e.consume();
            break;
        case (KeyEvent.VK_0):
            if (e.isShiftDown()) {
                tip.setVisible(false);
            }
            e.consume();
            break;
        case (KeyEvent.VK_LEFT):
        case (KeyEvent.VK_BACK_SPACE):
        case (KeyEvent.VK_DELETE):
            if (tip.isVisible()) {
                tip.setVisible(false);
            }
    }
}