本文整理汇总了Java中java.awt.event.KeyEvent.VK_META属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.VK_META属性的具体用法?Java KeyEvent.VK_META怎么用?Java KeyEvent.VK_META使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.event.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.VK_META属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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(); }
}
示例3: keyPressed
public void keyPressed(KeyEvent e) {
assert (e.getSource() instanceof JTextField);
if(((e.getModifiers() & (KeyEvent.ALT_MASK | KeyEvent.SHIFT_MASK | KeyEvent.CTRL_MASK | KeyEvent.META_MASK)) == 0) &&
(e.getKeyCode() == KeyEvent.VK_DOWN ||
e.getKeyCode() == KeyEvent.VK_UP ||
e.getKeyCode() == KeyEvent.VK_ESCAPE)) {
return ;
}
textField = (JTextField) e.getSource();
KeyStroke keyStroke = createKeyStroke(e);
boolean add = e.getKeyCode() != KeyEvent.VK_SHIFT &&
e.getKeyCode() != KeyEvent.VK_CONTROL &&
e.getKeyCode() != KeyEvent.VK_ALT &&
e.getKeyCode() != KeyEvent.VK_META &&
e.getKeyCode() != KeyEvent.VK_ALT_GRAPH;
if (!(enterConfirms && keyStroke.equals(enterKS))) {
if (keyStroke.equals(backspaceKS) && !key.equals("")) {
// delete last key
int i = key.lastIndexOf(' '); //NOI18N
if (i < 0) {
key = ""; //NOI18N
} else {
key = key.substring(0, i);
}
textField.setText(key);
} else {
// add key
addKeyStroke(keyStroke, add);
}
e.consume();
}
}
示例4: keyPressed
public void keyPressed (KeyEvent e) {
KeyStroke keyStroke = ShortcutListener.createKeyStroke(e);
boolean add = e.getKeyCode () != KeyEvent.VK_SHIFT &&
e.getKeyCode () != KeyEvent.VK_CONTROL &&
e.getKeyCode () != KeyEvent.VK_ALT &&
e.getKeyCode () != KeyEvent.VK_META &&
e.getKeyCode () != KeyEvent.VK_ALT_GRAPH;
if (keyStroke.equals (backspaceKS) && !key.equals ("")) {
// delete last key
int i = key.lastIndexOf (' '); //NOI18N
if (i < 0) {
key = ""; //NOI18N
} else {
key = key.substring (0, i);
}
getTfShortcut().setText (key);
} else {
// add key
addKeyStroke (keyStroke, add);
}
if (add) {
updateWarning();
} else {
setShortcutValid(false);
}
e.consume ();
}
示例5: getKeyStrokeAsText
/**
* Get human-readable name for a {@link KeyStroke}.
*/
public static String getKeyStrokeAsText(@NonNull KeyStroke keyStroke) {
int modifiers = keyStroke.getModifiers ();
StringBuilder sb = new StringBuilder ();
if ((modifiers & InputEvent.CTRL_DOWN_MASK) > 0) {
sb.append(EMACS_CTRL);
}
if ((modifiers & InputEvent.ALT_DOWN_MASK) > 0) {
sb.append(STRING_ALT);
}
if ((modifiers & InputEvent.SHIFT_DOWN_MASK) > 0) {
sb.append (EMACS_SHIFT);
}
if ((modifiers & InputEvent.META_DOWN_MASK) > 0) {
sb.append(STRING_META);
}
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: 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();
}
示例7: getKeyStrokeAsText
static String getKeyStrokeAsText (KeyStroke keyStroke) {
if (keyStroke == null)
return "";
int modifiers = keyStroke.getModifiers ();
StringBuffer sb = new StringBuffer ();
if ((modifiers & InputEvent.CTRL_DOWN_MASK) > 0)
sb.append ("Ctrl+");
if ((modifiers & InputEvent.ALT_DOWN_MASK) > 0)
sb.append ("Alt+");
if ((modifiers & InputEvent.SHIFT_DOWN_MASK) > 0)
sb.append ("Shift+");
if ((modifiers & InputEvent.META_DOWN_MASK) > 0)
if (Utilities.isMac()) {
// Mac cloverleaf symbol
sb.append ("\u2318+");
} else if (isSolaris()) {
// Sun meta symbol
sb.append ("\u25C6+");
} else {
sb.append ("Meta+");
}
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 ();
}
示例8: 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);
}
}
示例9: 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");
}
}
示例10: recordRawKeyEvent
@Override public void recordRawKeyEvent(RComponent r, KeyEvent e) {
JSONObject event = new JSONObject();
event.put("type", "key_raw");
int keyCode = e.getKeyCode();
if (keyCode == KeyEvent.VK_META || keyCode == KeyEvent.VK_SHIFT || keyCode == KeyEvent.VK_ALT
|| keyCode == KeyEvent.VK_CONTROL) {
return;
}
if ((e.isActionKey() || e.isControlDown() || e.isMetaDown() || e.isAltDown()) && e.getID() == KeyEvent.KEY_PRESSED) {
String mtext = buildModifiersText(e);
event.put("modifiersEx", mtext);
KeysMap keysMap = KeysMap.findMap(e.getKeyCode());
if (keysMap == KeysMap.NULL) {
return;
}
String keyText;
if (keysMap == null) {
keyText = KeyEvent.getKeyText(e.getKeyCode());
} else {
keyText = keysMap.toString();
}
event.put("keyCode", keyText);
} else if (e.getID() == KeyEvent.KEY_TYPED && !e.isControlDown()) {
if (Character.isISOControl(e.getKeyChar()) && hasMapping(e.getKeyChar())) {
event.put("keyChar", getMapping(e.getKeyChar()));
} else {
event.put("keyChar", "" + e.getKeyChar());
}
} else {
return;
}
recordEvent(r, event);
}
示例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: keyPressed
public void keyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_DELETE:
case KeyEvent.VK_BACK_SPACE:
setValue(NamedKeyStroke.NULL_KEYSTROKE);
break;
case KeyEvent.VK_SHIFT:
case KeyEvent.VK_CONTROL:
case KeyEvent.VK_META:
case KeyEvent.VK_ALT:
break;
default:
final NamedKeyStroke namedStroke = getValueNamedKeyStroke();
if (namedStroke != null) {
final int thisChar = e.getKeyChar();
if (isPrintableAscii(lastChar) && isPrintableAscii(thisChar)) {
final String name = "" + lastChar + e.getKeyChar();
named = true;
keyName.setText(name);
setValue(new NamedKeyStroke(name));
updateVisibility();
keyName.requestFocus();
break;
}
}
setValue(NamedKeyStroke.getKeyStrokeForEvent(e));
}
}
示例13: updateKeyStates
/**
* Helper method that keeps track of the pressed special keys (space, meta
* and alt key).
*
* @param keyEvent The key event to analyze.
*/
private void updateKeyStates(KeyEvent keyEvent) {
// update spaceKeyDown
if (keyEvent.getKeyCode() == KeyEvent.VK_SPACE) {
if (keyEvent.getID() == KeyEvent.KEY_RELEASED) {
spaceKeyDown = false;
} else if (keyEvent.getID() == KeyEvent.KEY_PRESSED) {
spaceKeyDown = true;
}
}
// update metaKeyDown
if (keyEvent.getKeyCode() == KeyEvent.VK_META) {
if (keyEvent.getID() == KeyEvent.KEY_RELEASED) {
metaKeyDown = false;
} else if (keyEvent.getID() == KeyEvent.KEY_PRESSED) {
metaKeyDown = true;
}
}
// update altKeyDown
if (keyEvent.getKeyCode() == KeyEvent.VK_ALT) {
if (keyEvent.getID() == KeyEvent.KEY_RELEASED) {
altKeyDown = false;
} else if (keyEvent.getID() == KeyEvent.KEY_PRESSED) {
altKeyDown = true;
}
}
}
示例14: doTest
void doTest() throws Exception {
ArrayList<Component> components = new ArrayList();
components.add(button);
components.add(buttonLW);
components.add(textField);
components.add(textArea);
components.add(list);
components.add(listLW);
int keys[];
String OS = System.getProperty("os.name").toLowerCase();
System.out.println(OS);
if (OS.contains("os x") || OS.contains("sunos")) {
keys = new int[] {KeyEvent.VK_SHIFT, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT, KeyEvent.VK_META};
} else {
keys = new int[] {KeyEvent.VK_SHIFT, KeyEvent.VK_CONTROL, KeyEvent.VK_ALT};
}
for (Component c: components) {
System.out.print(c.getClass().getName() + ": ");
Point origin = c.getLocationOnScreen();
int xc = origin.x + c.getWidth() / 2;
int yc = origin.y + c.getHeight() / 2;
Point center = new Point(xc, yc);
robot.delay(robotDelay);
robot.glide(origin, center);
robot.click();
robot.delay(robotDelay);
for (int k = 0; k < keys.length; ++k) {
keyPressReceived = false;
keyCode = keys[k];
robot.type(keyCode);
robot.delay(robotDelay);
if (!keyPressReceived) {
synchronized (lock) {
try {
lock.wait(waitDelay);
} catch (InterruptedException e) {}
}
}
assertTrue(keyPressReceived, "key press event was not received");
}
System.out.println("passed");
}
robot.waitForIdle();
frame.dispose();
}
示例15: getAction
public Action getAction(final KeyStroke key) {
switch (key.getKeyCode()) {
case KeyEvent.VK_SHIFT:
case KeyEvent.VK_CONTROL:
case KeyEvent.VK_ALT:
case KeyEvent.VK_ALT_GRAPH:
case KeyEvent.VK_META:
case KeyEvent.VK_UNDEFINED:
case KeyEvent.CHAR_UNDEFINED:
// Not actually a bindable key press.
return null;
}
if (key.isOnKeyRelease()) {
// Again, not really our business here.
return null;
}
LOG.log(Level.FINE, "getAction {0}", key);
Map<KeyStroke,Binding> binder = bindings();
for (KeyStroke ctx : context) {
Binding sub = binder.get(ctx);
if (sub == null) {
resetContext();
return BROKEN; // no entry found after known prefix
}
binder = sub.nested;
if (binder == null) {
resetContext();
return BROKEN; // anomalous, expected to find submap here
}
}
Binding b = binder.get(key);
if (b == null) {
resetContext();
return null; // normal, not found
}
if (b.nested == null) {
resetContext();
return b.loadAction(); // found real action
} else {
return new AbstractAction() {
public void actionPerformed(ActionEvent e) {
shiftContext(key); // entering submap
}
};
}
}