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


Java KeyEvent.ALT_MASK属性代码示例

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

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

示例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();
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:24,代码来源:HotKeyConfigurer.java

示例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;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:16,代码来源:HotkeySpecifier.java

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

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

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

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

示例9: ExecuteTestAction

/** creates new ExecuteTestAction instance */
public ExecuteTestAction() {
    super(MENU, MENU, new Action.Shortcut(KeyEvent.CTRL_MASK|KeyEvent.ALT_MASK, KeyEvent.VK_L));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:ExecuteTestAction.java

示例10: OpenTestAction

/** creates new OpenTestAction instance */
public OpenTestAction() {
    super(MENU, MENU, new Action.Shortcut(KeyEvent.CTRL_MASK|KeyEvent.ALT_MASK, KeyEvent.VK_K));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:OpenTestAction.java

示例11: CreateTestsAction

/** creates new CreateTestsAction instance */
public CreateTestsAction() {
    super(MENU, MENU, new Action.Shortcut(KeyEvent.CTRL_MASK|KeyEvent.ALT_MASK, KeyEvent.VK_J));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:CreateTestsAction.java

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

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


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