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


Java KeyStroke.isOnKeyRelease方法代码示例

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


在下文中一共展示了KeyStroke.isOnKeyRelease方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: keyCommand

import javax.swing.KeyStroke; //导入方法依赖的package包/类
/**
 * Classes other than the Chatter itself may forward KeyEvents
 * to the Chatter by using this method
 */
public void keyCommand(KeyStroke e) {
  if ((e.getKeyCode() == 0 || e.getKeyCode() == KeyEvent.CHAR_UNDEFINED)
      && !Character.isISOControl(e.getKeyChar())) {
    input.setText(input.getText() + e.getKeyChar());
  }
  else if (e.isOnKeyRelease()) {
    switch (e.getKeyCode()) {
      case KeyEvent.VK_ENTER:
        if (input.getText().length() > 0)
          send(formatChat(input.getText()));
        input.setText(""); //$NON-NLS-1$
        break;
      case KeyEvent.VK_BACK_SPACE:
      case KeyEvent.VK_DELETE:
        String s = input.getText();
        if (s.length() > 0)
          input.setText(s.substring(0, s.length() - 1));
        break;
    }
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:26,代码来源:Chatter.java

示例2: getAction

import javax.swing.KeyStroke; //导入方法依赖的package包/类
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,代码行数:47,代码来源:NbKeymap.java


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