当前位置: 首页>>代码示例>>Java>>正文


Java KeyEvent.VK_SHIFT属性代码示例

本文整理汇总了Java中java.awt.event.KeyEvent.VK_SHIFT属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.VK_SHIFT属性的具体用法?Java KeyEvent.VK_SHIFT怎么用?Java KeyEvent.VK_SHIFT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.awt.event.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.VK_SHIFT属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: keyPressed

@Override
public void keyPressed(Canvas canvas, KeyEvent e) {
	if (state == MOVING && e.getKeyCode() == KeyEvent.VK_SHIFT) {
		handleMoveDrag(canvas, curDx, curDy, e.getModifiersEx());
	} else {
		switch (e.getKeyCode()) {
		case KeyEvent.VK_BACK_SPACE:
		case KeyEvent.VK_DELETE:
			if (!canvas.getSelection().isEmpty()) {
				Action act = SelectionActions.clear(canvas.getSelection());
				canvas.getProject().doAction(act);
				e.consume();
			}
			break;
		default:
			processKeyEvent(canvas, e, KeyConfigurationEvent.KEY_PRESSED);
		}
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:19,代码来源:SelectTool.java

示例2: menuItem

/** Construct a new JMenuItem then add it to an existing JMenu.
 * @param parent - the JMenu to add this JMenuItem into (or null if you don't want to add it to any JMenu yet)
 * @param label - the text to show on the menu
 * @param attrs - a list of attributes to apply onto the new JMenuItem
 * <p> If one positive number  a is supplied, we call setMnemonic(a)
 * <p> If two positive numbers a and b are supplied, and a!=VK_ALT, and a!=VK_SHIFT, we call setMnemoic(a) and setAccelerator(b)
 * <p> If two positive numbers a and b are supplied, and a==VK_ALT or a==VK_SHIFT, we call setAccelerator(a | b)
 * <p> If an ActionListener is supplied, we call addActionListener(x)
 * <p> If an Boolean x      is supplied, we call setEnabled(x)
 * <p> If an Icon x         is supplied, we call setIcon(x)
 */
public static JMenuItem menuItem (JMenu parent, String label, Object... attrs) {
   JMenuItem m = new JMenuItem(label, null);
   int accelMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
   boolean hasMnemonic = false;
   for(Object x: attrs) {
      if (x instanceof Character || x instanceof Integer) {
         int k = (x instanceof Character) ? ((int)((Character)x)) : ((Integer)x).intValue();
         if (k < 0) continue;
         if (k==KeyEvent.VK_ALT)   { hasMnemonic = true; accelMask = accelMask | InputEvent.ALT_MASK;   continue; }
         if (k==KeyEvent.VK_SHIFT) { hasMnemonic = true; accelMask = accelMask | InputEvent.SHIFT_MASK; continue; }
         if (!hasMnemonic) { m.setMnemonic(k); hasMnemonic=true; } else m.setAccelerator(KeyStroke.getKeyStroke(k, accelMask));
      }
      if (x instanceof ActionListener) m.addActionListener((ActionListener)x);
      if (x instanceof Icon) m.setIcon((Icon)x);
      if (x instanceof Boolean) m.setEnabled((Boolean)x);
   }
   if (parent!=null) parent.add(m);
   return m;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:30,代码来源:OurUtil.java

示例3: keyPressed

@Override
public void keyPressed(Canvas canvas, KeyEvent e) {
	int code = e.getKeyCode();
	if (active && (code == KeyEvent.VK_SHIFT || code == KeyEvent.VK_ALT || code == KeyEvent.VK_CONTROL)) {
		updateMouse(canvas, lastMouseX, lastMouseY, e.getModifiersEx());
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:7,代码来源:RectangularTool.java

示例4: keyPressed

@Override
public void keyPressed(KeyEvent e) {

    keyPressReceived = true;

    int code = e.getKeyCode();

    assertEQ(code, keyCode, "wrong key code");

    int mask = 0;

    if (code == KeyEvent.VK_SHIFT) {
        mask = InputEvent.SHIFT_MASK;
    } else if (code == KeyEvent.VK_CONTROL) {
        mask = InputEvent.CTRL_MASK;
    } else if (code == KeyEvent.VK_ALT) {
        mask = InputEvent.ALT_MASK;
    } else if (code == KeyEvent.VK_META) {
        mask = InputEvent.META_MASK;
    }

    int mod = e.getModifiers() & mask;
    assertEQ(mod, mask, "invalid key mask");

    synchronized (lock) { lock.notifyAll(); }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:KeyMaskTest.java

示例5: keyStrokeToString

public static String keyStrokeToString(KeyStroke keyStroke) {
    int modifiers = keyStroke.getModifiers();
    StringBuffer sb = new StringBuffer();
    if ((modifiers & InputEvent.CTRL_DOWN_MASK) > 0) {
        sb.append("Ctrl+"); // NOI18N
    }
    if ((modifiers & InputEvent.ALT_DOWN_MASK) > 0) {
        sb.append("Alt+"); // NOI18N
    }
    if ((modifiers & InputEvent.SHIFT_DOWN_MASK) > 0) {
        sb.append("Shift+"); // NOI18N
    }
    if ((modifiers & InputEvent.META_DOWN_MASK) > 0) {
        sb.append("Meta+"); // NOI18N
    }
    if (keyStroke.getKeyCode() != KeyEvent.VK_SHIFT &&
            keyStroke.getKeyCode() != KeyEvent.VK_CONTROL &&
            keyStroke.getKeyCode() != KeyEvent.VK_META &&
            keyStroke.getKeyCode() != KeyEvent.VK_ALT &&
            keyStroke.getKeyCode() != KeyEvent.VK_ALT_GRAPH) {
        sb.append(Utilities.keyToString(
                KeyStroke.getKeyStroke(keyStroke.getKeyCode(), 0)));
    }
    return sb.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:WizardUtils.java

示例6: getKeyEvent

public int getKeyEvent(String key) {
    switch (key.toUpperCase()) {
        case "TAB":
            return KeyEvent.VK_TAB;
        case "ENTER":
            return KeyEvent.VK_ENTER;
        case "SHIFT":
            return KeyEvent.VK_SHIFT;
        case "CTRL":
            return KeyEvent.VK_CONTROL;
        case "ALT":
            return KeyEvent.VK_ALT;
        case "START":
            return KeyEvent.VK_WINDOWS;
        case "DELETE":
            return KeyEvent.VK_DELETE;
        case "BACKSPACE":
            return KeyEvent.VK_BACK_SPACE;
        case "HOME":
            return KeyEvent.VK_HOME;
        case "PAGE_UP":
        case "PAGEUP":
            return KeyEvent.VK_PAGE_UP;
        case "PAGE_DOWN":
        case "PAGEDOWN":
            return KeyEvent.VK_PAGE_DOWN;
        case "UP":
            return KeyEvent.VK_UP;
        case "DOWN":
            return KeyEvent.VK_DOWN;
        case "LEFT":
            return KeyEvent.VK_LEFT;
        case "RIGHT":
            return KeyEvent.VK_RIGHT;
        default:
            return KeyEvent.VK_ESCAPE;
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:38,代码来源:ImageCommand.java

示例7: getKeyStrokeAsText

private static String getKeyStrokeAsText(KeyStroke keyStroke) {
    int modifiers = keyStroke.getModifiers();
    StringBuilder sb = new StringBuilder();
    sb.append('\'');
    if ((modifiers & InputEvent.CTRL_DOWN_MASK) > 0) {
        sb.append("Ctrl+"); //NOI18N
    }
    if ((modifiers & InputEvent.ALT_DOWN_MASK) > 0) {
        sb.append("Alt+"); //NOI18N
    }
    if ((modifiers & InputEvent.SHIFT_DOWN_MASK) > 0) {
        sb.append("Shift+"); //NOI18N
    }
    if ((modifiers & InputEvent.META_DOWN_MASK) > 0) {
        sb.append("Meta+"); //NOI18N
    }
    if (keyStroke.getKeyCode() != KeyEvent.VK_SHIFT
            && keyStroke.getKeyCode() != KeyEvent.VK_CONTROL
            && keyStroke.getKeyCode() != KeyEvent.VK_META
            && keyStroke.getKeyCode() != KeyEvent.VK_ALT
            && keyStroke.getKeyCode() != KeyEvent.VK_ALT_GRAPH) {
        sb.append(org.openide.util.Utilities.keyToString(
                KeyStroke.getKeyStroke(keyStroke.getKeyCode(), 0)
        ));
    }
    sb.append('\'');
    return sb.toString();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:InstantRefactoringPerformer.java

示例8: keyPressed

@Override
public void keyPressed(Canvas canvas, KeyEvent e) {
	int code = e.getKeyCode();
	if (active && (code == KeyEvent.VK_SHIFT || code == KeyEvent.VK_CONTROL)) {
		updateMouse(canvas, lastMouseX, lastMouseY, e.getModifiersEx());
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:7,代码来源:LineTool.java

示例9: updateFilter

private void updateFilter(KeyEvent e) {
	String filterText = getText();
	if ((filterText == null) || (filterText.length() == 0)) {
		if ((e == null)
				|| ((e.getKeyCode() != KeyEvent.VK_BACK_SPACE) && (e.getKeyCode() != KeyEvent.VK_DELETE)
						&& (e.getKeyCode() != KeyEvent.VK_SHIFT) && (e.getKeyCode() != KeyEvent.VK_ALT)
						&& (e.getKeyCode() != KeyEvent.VK_ALT_GRAPH) && (e.getKeyCode() != KeyEvent.VK_CONTROL)
						&& (e.getKeyCode() != KeyEvent.VK_META) && (!e.isActionKey()))) {
			setText(null);
		}
	}
	for (FilterListener l : filterListeners) {
		l.valueChanged(filterText);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:15,代码来源:FilterTextField.java

示例10: getModifier

private int getModifier(int keycode) {
    switch (keycode) {
    case KeyEvent.VK_SHIFT:
        return InputEvent.SHIFT_MASK;
    case KeyEvent.VK_CONTROL:
        return InputEvent.CTRL_MASK;
    case KeyEvent.VK_ALT:
        return InputEvent.ALT_MASK;
    case KeyEvent.VK_META:
        return InputEvent.META_MASK;
    default:
        throw new RuntimeException(OSUtils.keyEventGetKeyText(keycode) + " is not a valid modifier");
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:KeyStrokeParser.java

示例11: keyPressed

public void keyPressed(KeyEvent e) {
  switch (e.getKeyCode()) {
    case KeyEvent.VK_DELETE:
    case KeyEvent.VK_BACK_SPACE:
      setValue(null);
      break;
    case KeyEvent.VK_SHIFT:
    case KeyEvent.VK_CONTROL:
    case KeyEvent.VK_META:
    case KeyEvent.VK_ALT:
      break;
    default:
      setValue(KeyStroke.getKeyStrokeForEvent(e));
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:15,代码来源:HotKeyConfigurer.java

示例12: ModifierRobotEnhancedKeyTest

public ModifierRobotEnhancedKeyTest() throws Exception {
    modifierKeys =  new int[4];
    modifierKeys[0] = KeyEvent.VK_SHIFT;
    modifierKeys[1] = KeyEvent.VK_CONTROL;
    modifierKeys[2] = KeyEvent.VK_ALT;
    modifierKeys[3] = KeyEvent.VK_ALT_GRAPH;

    inputMasks = new int[4];
    inputMasks[0] =  InputEvent.SHIFT_MASK;
    inputMasks[1] =  InputEvent.CTRL_MASK;
    inputMasks[2] =  InputEvent.ALT_MASK;
    inputMasks[3] =  InputEvent.ALT_GRAPH_MASK;

    modifierStatus = new boolean[modifierKeys.length];

    textKeys = new int[6];
    textKeys[0] = KeyEvent.VK_A;
    textKeys[1] = KeyEvent.VK_S;
    textKeys[2] = KeyEvent.VK_DELETE;
    textKeys[3] = KeyEvent.VK_HOME;
    textKeys[4] = KeyEvent.VK_F12;
    textKeys[5] = KeyEvent.VK_LEFT;

    textStatus = new boolean[textKeys.length];

    EventQueue.invokeAndWait( () -> { initializeGUI(); });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:ModifierRobotEnhancedKeyTest.java

示例13: keyReleased

@Override
public void keyReleased(KeyEvent ke) {
    int k = ke.getKeyCode();
    if (k == KeyEvent.VK_SHIFT) {
        shiftPressed = false;
    } else if (k == KeyEvent.VK_CONTROL) {
        ctlPressed = false;
    } else if (k == KeyEvent.VK_ALT) {
        altPressed = false;
    } else if (k == KeyEvent.VK_E) {
        setEraseSamplesEnabled(false);
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:13,代码来源:TargetLabeler.java

示例14: keyReleased

public void keyReleased(KeyEvent e) {
    int keycode = e.getKeyCode();
    switch(keycode) {
    case KeyEvent.VK_CONTROL:
        _control = false;
        break;
    case KeyEvent.VK_SHIFT:
        _shift = false;
        break;
    default:
        // None
    }
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:13,代码来源:PlotBox.java

示例15: menuItem

/**
 * Construct a new JMenuItem then add it to an existing JMenu.
 * 
 * @param parent - the JMenu to add this JMenuItem into (or null if you
 *            don't want to add it to any JMenu yet)
 * @param label - the text to show on the menu
 * @param attrs - a list of attributes to apply onto the new JMenuItem
 *            <p>
 *            If one positive number a is supplied, we call setMnemonic(a)
 *            <p>
 *            If two positive numbers a and b are supplied, and a!=VK_ALT,
 *            and a!=VK_SHIFT, we call setMnemoic(a) and setAccelerator(b)
 *            <p>
 *            If two positive numbers a and b are supplied, and a==VK_ALT or
 *            a==VK_SHIFT, we call setAccelerator(a | b)
 *            <p>
 *            If an ActionListener is supplied, we call addActionListener(x)
 *            <p>
 *            If an Boolean x is supplied, we call setEnabled(x)
 *            <p>
 *            If an Icon x is supplied, we call setIcon(x)
 */
public static JMenuItem menuItem(JMenu parent, String label, Object... attrs) {
	JMenuItem m = new JMenuItem(label, null);
	int accelMask = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
	boolean hasMnemonic = false;
	for (Object x : attrs) {
		if (x instanceof Character || x instanceof Integer) {
			int k = (x instanceof Character) ? ((int) ((Character) x)) : ((Integer) x).intValue();
			if (k < 0)
				continue;
			if (k == KeyEvent.VK_ALT) {
				hasMnemonic = true;
				accelMask = accelMask | InputEvent.ALT_MASK;
				continue;
			}
			if (k == KeyEvent.VK_SHIFT) {
				hasMnemonic = true;
				accelMask = accelMask | InputEvent.SHIFT_MASK;
				continue;
			}
			if (!hasMnemonic) {
				m.setMnemonic(k);
				hasMnemonic = true;
			} else
				m.setAccelerator(KeyStroke.getKeyStroke(k, accelMask));
		}
		if (x instanceof ActionListener)
			m.addActionListener((ActionListener) x);
		if (x instanceof Icon)
			m.setIcon((Icon) x);
		if (x instanceof Boolean)
			m.setEnabled((Boolean) x);
	}
	if (parent != null)
		parent.add(m);
	return m;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:58,代码来源:OurUtil.java


注:本文中的java.awt.event.KeyEvent.VK_SHIFT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。