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

The following examples show how to use java.awt.event.KeyEvent#VK_8 . 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: 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 3
Source File: KeyRemappingConfig.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@ConfigItem(
	position = 14,
	keyName = "f8",
	name = "F8",
	description = "The key which will replace {F8}."
)
default ModifierlessKeybind f8()
{
	return new ModifierlessKeybind(KeyEvent.VK_8, 0);
}
 
Example 4
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 5
Source File: KeyRemappingConfig.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@ConfigItem(
	position = 14,
	keyName = "f8",
	name = "F8",
	description = "The key which will replace {F8}.",
	section = fKeySection
)
default ModifierlessKeybind f8()
{
	return new ModifierlessKeybind(KeyEvent.VK_8, 0);
}
 
Example 6
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 7
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 8
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 9
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 10
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();
}