本文整理汇总了Java中java.awt.event.KeyEvent.ALT_MASK属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.ALT_MASK属性的具体用法?Java KeyEvent.ALT_MASK怎么用?Java KeyEvent.ALT_MASK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.awt.event.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.ALT_MASK属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: appendKeyMnemonic
public static String appendKeyMnemonic(StringBuilder sb, KeyStroke key) {
String sk = org.openide.util.Utilities.keyToString(key);
int mods = key.getModifiers();
if ((mods & KeyEvent.CTRL_MASK) != 0) {
sb.append("Ctrl+"); // NOI18N
}
if ((mods & KeyEvent.ALT_MASK) != 0) {
sb.append("Alt+"); // NOI18N
}
if ((mods & KeyEvent.SHIFT_MASK) != 0) {
sb.append("Shift+"); // NOI18N
}
if ((mods & KeyEvent.META_MASK) != 0) {
sb.append("Meta+"); // NOI18N
}
int i = sk.indexOf('-'); //NOI18N
if (i != -1) {
sk = sk.substring(i + 1);
}
sb.append(sk);
return sb.toString();
}
示例2: usableKeyOnMac
private static boolean usableKeyOnMac(int key, int mask) {
//All permutations fail for Q except ctrl
if (key == KeyEvent.VK_Q) {
return false;
}
boolean isMeta = ((mask & KeyEvent.META_MASK) != 0) || ((mask & KeyEvent.CTRL_DOWN_MASK) != 0);
boolean isAlt = ((mask & KeyEvent.ALT_MASK) != 0) || ((mask & KeyEvent.ALT_DOWN_MASK) != 0);
boolean isOnlyMeta = isMeta && ((mask & ~(KeyEvent.META_DOWN_MASK | KeyEvent.META_MASK)) == 0);
//Mac OS consumes keys Command+ these keys - the app will never see
//them, so CTRL should not be remapped for these
if (isOnlyMeta) {
return (key != KeyEvent.VK_H) && (key != KeyEvent.VK_SPACE) && (key != KeyEvent.VK_TAB);
}
if ((key == KeyEvent.VK_D) && isMeta && isAlt) {
return false;
}
if (key == KeyEvent.VK_SPACE && isMeta && ((mask & KeyEvent.CTRL_MASK) != 0)) {
// http://lists.apple.com/archives/java-dev/2010/Aug/msg00002.html
return false;
}
return true;
}
示例3: getString
/**
* A plain text representation of a KeyStroke. Doesn't differ much
* from {@link KeyEvent#getKeyText}
*/
public static String getString(KeyStroke k) {
if (k == null) {
return null;
}
String s = KeyEvent.getKeyText(k.getKeyCode());
s = s.replace(' ', '_');
if ((k.getModifiers() & KeyEvent.SHIFT_MASK) > 0) {
s = Resources.getString("Keys.shift") + " " + s; //$NON-NLS-1$ //$NON-NLS-2$
}
if ((k.getModifiers() & KeyEvent.CTRL_MASK) > 0) {
s = Resources.getString("Keys.ctrl") + " " + s; //$NON-NLS-1$ //$NON-NLS-2$
}
if ((k.getModifiers() & KeyEvent.META_MASK) > 0) {
s = Resources.getString("Keys.meta") + " " + s; //$NON-NLS-1$ //$NON-NLS-2$
}
if ((k.getModifiers() & KeyEvent.ALT_MASK) > 0) {
s = Resources.getString("Keys.alt") + " " + s; //$NON-NLS-1$ //$NON-NLS-2$
}
return s.toUpperCase();
}
示例4: getString
public static String getString(KeyStroke k) {
String s = KeyEvent.getKeyText(k.getKeyCode());
if ((k.getModifiers() & KeyEvent.SHIFT_MASK) > 0) {
s = KeyEvent.getKeyText(KeyEvent.VK_SHIFT) + "+" + s;
}
if ((k.getModifiers() & KeyEvent.CTRL_MASK) > 0) {
s = KeyEvent.getKeyText(KeyEvent.VK_CONTROL) + "+" + s;
}
if ((k.getModifiers() & KeyEvent.META_MASK) > 0) {
s = KeyEvent.getKeyText(KeyEvent.VK_META) + "+" + s;
}
if ((k.getModifiers() & KeyEvent.ALT_MASK) > 0) {
s = KeyEvent.getKeyText(KeyEvent.VK_ALT) + "+" + s;
}
return s;
}
示例5: addModifiers
/** Adds characters for modifiers to the buffer.
* @param buf buffer to add to
* @param modif modifiers to add (KeyEvent.XXX_MASK)
* @return true if something has been added
*/
private static boolean addModifiers(StringBuilder buf, int modif) {
boolean b = false;
if ((modif & KeyEvent.CTRL_MASK) != 0) {
buf.append("C"); // NOI18N
b = true;
}
if ((modif & KeyEvent.ALT_MASK) != 0) {
buf.append("A"); // NOI18N
b = true;
}
if ((modif & KeyEvent.SHIFT_MASK) != 0) {
buf.append("S"); // NOI18N
b = true;
}
if ((modif & KeyEvent.META_MASK) != 0) {
buf.append("M"); // NOI18N
b = true;
}
if ((modif & CTRL_WILDCARD_MASK) != 0) {
buf.append("D");
b = true;
}
if ((modif & ALT_WILDCARD_MASK) != 0) {
buf.append("O");
b = true;
}
return b;
}
示例6: addModifiersPortable
private static boolean addModifiersPortable(StringBuilder buf, int modifiers) {
boolean b = false;
if ((modifiers & KeyEvent.SHIFT_MASK) != 0) {
buf.append('S');
b = true;
}
if (Utilities.isMac() && ((modifiers & KeyEvent.META_MASK) != 0) || !Utilities.isMac() && ((modifiers & KeyEvent.CTRL_MASK) != 0)) {
buf.append('D');
b = true;
}
if (Utilities.isMac() && ((modifiers & KeyEvent.CTRL_MASK) != 0) || !Utilities.isMac() && ((modifiers & KeyEvent.ALT_MASK) != 0)) {
buf.append('O');
b = true;
}
// mac alt fallback
if (Utilities.isMac() && ((modifiers & KeyEvent.ALT_MASK) != 0)) {
buf.append('A');
b = true;
}
// META fallback, see issue #224362
if (!Utilities.isMac() && ((modifiers & KeyEvent.META_MASK) != 0)) {
buf.append('M');
b = true;
}
return b;
}
示例7: 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();
}
}
示例8: keyPressed
@Override
public void keyPressed(KeyEvent evt) {
if(evt.getKeyCode() == KeyEvent.VK_UP && (evt.getModifiers() & KeyEvent.ALT_MASK) == KeyEvent.ALT_MASK) {
Action action = getChangeToParentDirectoryAction();
action.actionPerformed(new ActionEvent(evt.getSource(), 0, ""));
component.requestFocus();
}
}
示例9: ExecuteTestAction
/** creates new ExecuteTestAction instance */
public ExecuteTestAction() {
super(MENU, MENU, new Action.Shortcut(KeyEvent.CTRL_MASK|KeyEvent.ALT_MASK, KeyEvent.VK_L));
}
示例10: OpenTestAction
/** creates new OpenTestAction instance */
public OpenTestAction() {
super(MENU, MENU, new Action.Shortcut(KeyEvent.CTRL_MASK|KeyEvent.ALT_MASK, KeyEvent.VK_K));
}
示例11: CreateTestsAction
/** creates new CreateTestsAction instance */
public CreateTestsAction() {
super(MENU, MENU, new Action.Shortcut(KeyEvent.CTRL_MASK|KeyEvent.ALT_MASK, KeyEvent.VK_J));
}
示例12: processKeyBinding
protected @Override boolean processKeyBinding(KeyStroke ks,
KeyEvent e,
int condition,
boolean pressed) {
if (Utilities.isMac()) {
int mods = e.getModifiers();
boolean isCtrl = (mods & KeyEvent.CTRL_MASK) != 0;
boolean isAlt = (mods & KeyEvent.ALT_MASK) != 0;
if (isAlt && (e instanceof MarkedKeyEvent)) {
mods = mods & ~ KeyEvent.CTRL_MASK;
mods = mods & ~ KeyEvent.CTRL_DOWN_MASK;
mods |= KeyEvent.ALT_MASK;
mods |= KeyEvent.ALT_DOWN_MASK;
KeyEvent newEvent = new MarkedKeyEvent (
(Component) e.getSource(), e.getID(),
e.getWhen(), mods, e.getKeyCode(), e.getKeyChar(),
e.getKeyLocation());
KeyStroke newStroke = null;
if( null != ks ) {
newStroke = e.getID() == KeyEvent.KEY_TYPED ?
KeyStroke.getKeyStroke (ks.getKeyChar(), mods) :
KeyStroke.getKeyStroke (ks.getKeyCode(), mods,
!ks.isOnKeyRelease());
}
boolean result = super.processKeyBinding (newStroke,
newEvent, condition, pressed);
if (newEvent.isConsumed()) {
e.consume();
}
return result;
} else if (!isAlt) {
return super.processKeyBinding (ks, e, condition, pressed);
} else {
return false;
}
} else {
return super.processKeyBinding (ks, e, condition, pressed);
}
}
示例13: readModifiers
/** Reads for modifiers and creates integer with required mask.
* @param s string with modifiers
* @return integer with mask
* @exception NoSuchElementException if some letter is not modifier
*/
private static int readModifiers(String s) throws NoSuchElementException {
int m = 0;
for (int i = 0; i < s.length(); i++) {
switch (s.charAt(i)) {
case 'C':
m |= KeyEvent.CTRL_MASK;
break;
case 'A':
m |= KeyEvent.ALT_MASK;
break;
case 'M':
m |= KeyEvent.META_MASK;
break;
case 'S':
m |= KeyEvent.SHIFT_MASK;
break;
case 'D':
m |= CTRL_WILDCARD_MASK;
break;
case 'O':
m |= ALT_WILDCARD_MASK;
break;
default:
throw new NoSuchElementException(s);
}
}
return m;
}