本文整理汇总了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);
}
}
}
示例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;
}
示例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());
}
}
示例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(); }
}
示例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();
}
示例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;
}
}
示例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();
}
示例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());
}
}
示例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);
}
}
示例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");
}
}
示例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));
}
}
示例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(); });
}
示例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);
}
}
示例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
}
}
示例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;
}