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


Java KeyEvent.CTRL_MASK属性代码示例

本文整理汇总了Java中java.awt.event.KeyEvent.CTRL_MASK属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.CTRL_MASK属性的具体用法?Java KeyEvent.CTRL_MASK怎么用?Java KeyEvent.CTRL_MASK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.awt.event.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.CTRL_MASK属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: processKeyEvent

@Override
public void processKeyEvent(KeyEvent e) {
    //Manually hook in the bindings for tab - does not seem to get called
    //automatically
    if (isEditing() && ((e.getKeyCode() == KeyEvent.VK_DOWN) || (e.getKeyCode() == KeyEvent.VK_UP))) {
        return; //XXX
    }

    //Bypass standard tab and escape handling, and use our registered
    //actions instead
    if (
        !isEditing() ||
            (((e.getKeyCode() != KeyEvent.VK_TAB) && (e.getKeyCode() != KeyEvent.VK_ESCAPE)) ||
            ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0))
    ) {
        super.processKeyEvent(e);
    } else {
        processKeyBinding(
            KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiersEx(), e.getID() == KeyEvent.KEY_RELEASED), e,
            JComponent.WHEN_FOCUSED, e.getID() == KeyEvent.KEY_PRESSED
        );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:TreeTable.java

示例4: 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

示例5: 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

示例6: keyTyped

@Override
public void keyTyped(KeyEvent e) {
    key = e.getKeyChar();
    if (key == (char) 127 || key == '\b' || key == '\n') {
        e.consume();
        return;
    }

    if (e.getModifiers() == KeyEvent.CTRL_MASK) {
        return;
    }

    palavra = insertChar(palavra, key);
    posCursor++;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:15,代码来源:MasterCli.java

示例7: 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

示例8: 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

示例9: ctrlPressKey

private void ctrlPressKey(final Component target, final int key) throws Exception {
    if (SwingUtilities.isEventDispatchThread()) {
        KeyEvent k = new KeyEvent(target, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), KeyEvent.CTRL_MASK, key, (char) key);
        target.dispatchEvent(k);
    } else {
        
        SwingUtilities.invokeAndWait(new Runnable() {
            public void run() {
                KeyEvent ke = new KeyEvent(target, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), KeyEvent.CTRL_MASK, key, (char) key);
                target.dispatchEvent(ke);
            }
        });
        sleep();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:EditableDisplayerTest.java

示例10: 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

示例11: testToStringOfDelegateContainsNameOfOriginalAction

public void testToStringOfDelegateContainsNameOfOriginalAction() throws Exception {
    SaveAction sa = SaveAction.get(SaveAction.class);
    Action a = sa.createContextAwareInstance(Lookup.EMPTY);
    if (a.toString().indexOf("SaveAction") == -1) {
        fail("We need name of the original action:\n" + a.toString());
    }

    SaveAction.cnt = 0;
    CharSequence log = Log.enable("org.netbeans.ui", Level.FINER);
    
    final TopComponent tc = new TopComponent();
    final KeyEvent ke = new KeyEvent(tc, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), KeyEvent.CTRL_MASK, 0, 'S');
    final KeyStroke ks = KeyStroke.getKeyStrokeForEvent(ke);
    MockServices.setServices(MyKM.class);
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            tc.setActivatedNodes( new Node[0] );
            tc.processKeyBinding(ks, ke, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, true);
        }
        
    });
    
    if (log.toString().indexOf("SaveAction") == -1 
            && SaveAction.cnt == 1 ) { //make sure the action was actually invoked
        fail(log.toString());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:TopComponentTest.java

示例12: PrintPreviewComponent

public PrintPreviewComponent(RamusPrintable printable, int columnCount,
                             GUIFramework framework) {
    this.printable = printable;
    this.columnCount = columnCount;
    this.framework = framework;
    MouseWheelListener l = new MouseWheelListener() {

        @Override
        public void mouseWheelMoved(MouseWheelEvent e) {
            if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) {
                if (e.getModifiers() == KeyEvent.CTRL_MASK) {
                    double r = e.getWheelRotation();
                    double zoom = getZoom() - 0.2 * r;
                    setCurrentZoom(zoom);
                } else {
                    Rectangle rect = getVisibleRect();
                    scrollRectToVisible(new Rectangle(rect.x, rect.y
                            + e.getWheelRotation() * 150, rect.width,
                            rect.height));
                }
            }
        }
    };
    this.addMouseWheelListener(l);
    layout = Options.getInteger("PREVIW_LAYOUT", PREV_LAYOUT_GRID);
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
            setCurrentZoom(Options.getDouble("PREV_ZOOM", 1d));
        }
    });
    setCurrentZoom(Options.getDouble("PREV_ZOOM", 1d));
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:34,代码来源:PrintPreviewComponent.java

示例13: doCtrlPressKey

private void doCtrlPressKey(final Component target, final int key) throws Exception {
    
    KeyEvent k = new KeyEvent(target, KeyEvent.KEY_PRESSED, System.currentTimeMillis(), KeyEvent.CTRL_MASK, key, (char) key);
    target.dispatchEvent(k);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:EditableDisplayerTest.java

示例14: 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

示例15: 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


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