當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。