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


Java KeyEvent.VK_META属性代码示例

本文整理汇总了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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:WizardUtils.java

示例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(); }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:KeyMaskTest.java

示例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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:ShortcutListener.java

示例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 ();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:ShortcutsDialog.java

示例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 ();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:KeyStrokeUtils.java

示例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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:InstantRefactoringPerformer.java

示例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 ();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:SearchResultRender.java

示例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);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:15,代码来源:FilterTextField.java

示例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");
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:14,代码来源:KeyStrokeParser.java

示例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);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:33,代码来源:WSRecorder.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: 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));
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:28,代码来源:NamedHotKeyConfigurer.java

示例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;
        }
    }
}
 
开发者ID:berniejenny,项目名称:MapAnalyst,代码行数:34,代码来源:MapEventHandler.java

示例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();
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:60,代码来源:KeyMaskTest.java

示例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
            }
        };
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:46,代码来源:NbKeymap.java


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