javax.swing.JTextField.processKeyEvent()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(167)

本文整理了Java中javax.swing.JTextField.processKeyEvent()方法的一些代码示例,展示了JTextField.processKeyEvent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextField.processKeyEvent()方法的具体详情如下:
包路径:javax.swing.JTextField
类名称:JTextField
方法名:processKeyEvent

JTextField.processKeyEvent介绍

暂无

代码示例

代码示例来源:origin: JetBrains/ideavim

protected void processKeyEvent(KeyEvent e) {
 if (logger.isDebugEnabled()) logger.debug("key=" + e);
 super.processKeyEvent(e);
}

代码示例来源:origin: JetBrains/ideavim

public void handleKey(@NotNull KeyStroke stroke) {
 if (logger.isDebugEnabled()) logger.debug("stroke=" + stroke);
 final char keyChar = stroke.getKeyChar();
 char c = keyChar;
 final int modifiers = stroke.getModifiers();
 final int keyCode = stroke.getKeyCode();
 if ((modifiers & KeyEvent.CTRL_MASK) != 0) {
  final int codePoint = keyCode - KeyEvent.VK_A + 1;
  if (codePoint > 0) {
   c = Character.toChars(codePoint)[0];
  }
 }
 KeyEvent event = new KeyEvent(this, keyChar != KeyEvent.CHAR_UNDEFINED ? KeyEvent.KEY_TYPED :
                   (stroke.isOnKeyRelease() ? KeyEvent.KEY_RELEASED : KeyEvent.KEY_PRESSED),
                (new Date()).getTime(), modifiers, keyCode, c);
 super.processKeyEvent(event);
}

代码示例来源:origin: org.netbeans.api/org-openide-awt

@Override
  public void processKeyEvent(KeyEvent ke) {
    //override the default handling so that
    //the parent will never receive the escape key and
    //close a modal dialog
    if (ke.getKeyCode() == KeyEvent.VK_ESCAPE) {
      removeSearchField();
      ke.consume();
      // bugfix #32909, reqest focus when search field is removed
      requestOriginalFocusOwner();
      //fireQuickSearchCanceled();
      callback.quickSearchCanceled();
    } else {
      super.processKeyEvent(ke);
    }
  }
};

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-notifications

@Override
  protected void processKeyEvent(KeyEvent e) {
    super.processKeyEvent(e);
  }
}

代码示例来源:origin: org.quickfixj/quickfixj-examples-banzai

public void processKeyEvent(KeyEvent e) {
    char keyChar = e.getKeyChar();
    if (((keyChar >= '0') && (keyChar <= '9')) ||
        (keyChar == 8) || (keyChar == 127)) {
      super.processKeyEvent(e);
    }
  }
}

代码示例来源:origin: senbox-org/snap-desktop

@Override
  protected void processKeyEvent(KeyEvent e) {
    if (!Character.isLetter(e.getKeyChar()) && disallowedChars.indexOf(e.getKeyChar()) == -1) {
      super.processKeyEvent(e);
    }
  }
}

代码示例来源:origin: senbox-org/snap-desktop

@Override
  protected void processKeyEvent(KeyEvent e) {
    if (!Character.isLetter(e.getKeyChar()) && disallowedChars.indexOf(e.getKeyChar()) == -1) {
      super.processKeyEvent(e);
    }
  }
}

代码示例来源:origin: bcdev/beam

@Override
  protected void processKeyEvent(KeyEvent e) {
    if (!Character.isLetter(e.getKeyChar()) && disallowedChars.indexOf(e.getKeyChar()) == -1) {
      super.processKeyEvent(e);
    }
  }
}

代码示例来源:origin: org.quickfixj/quickfixj-examples-banzai

public void processKeyEvent(KeyEvent e) {
  char keyChar = e.getKeyChar();
  if (((keyChar >= '0') && (keyChar <= '9')) ||
      (keyChar == 8) || (keyChar == 127)) {
    super.processKeyEvent(e);
  } else if (keyChar == '.') {
    String text = getText();
    if (!text.contains(".")) {
      super.processKeyEvent(e);
    }
  }
}

代码示例来源:origin: bcdev/beam

@Override
  protected void processKeyEvent(KeyEvent e) {
    if (!Character.isLetter(e.getKeyChar()) && disallowedChars.indexOf(e.getKeyChar()) == -1) {
      super.processKeyEvent(e);
    }
  }
}

代码示例来源:origin: in.jlibs/org-netbeans-swing-outline

@Override
  public void processKeyEvent(KeyEvent ke) {
    //override the default handling so that
    //the parent will never receive the escape key and
    //close a modal dialog
    if (ke.getKeyCode() == KeyEvent.VK_ESCAPE) {
      removeSearchField();
      // bugfix #32909, reqest focus when search field is removed
      SwingUtilities.invokeLater(new Runnable() {
        //additional bugfix - do focus change later or removing
        //the component while it's focused will cause focus to
        //get transferred to the next component in the
        //parent focusTraversalPolicy *after* our request
        //focus completes, so focus goes into a black hole - Tim
        public void run() {
          ETable.this.requestFocus();
        }
      });
    } else {
      super.processKeyEvent(ke);
    }
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

@Override
  public void processKeyEvent(KeyEvent ke) {
    //override the default handling so that
    //the parent will never receive the escape key and
    //close a modal dialog
    if (ke.getKeyCode() == KeyEvent.VK_ESCAPE) {
      removeSearchField();
      ke.consume(); // #44394
      // bugfix #32909, reqest focus when search field is removed
      NbList.this.requestFocus();
    } else {
      super.processKeyEvent(ke);
    }
  }
};

代码示例来源:origin: org.bitbucket.goalhub.simpleide/jedit

@Override
  protected void processKeyEvent(KeyEvent e)
  {
    if (e.getID() == KeyEvent.KEY_TYPED)
    {
      if (!Character.isDigit(e.getKeyChar()) && !(!positiveOnly && e.getKeyChar() == '-'))
      {
        e.consume();
      }
    }
    super.processKeyEvent(e);
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

public void processKeyEvent(KeyEvent e) {
  super.processKeyEvent(e);
  if (e.getID() != KeyEvent.KEY_PRESSED) return;
  
  int keyCode = e.getKeyCode();
  if (keyCode == KeyEvent.VK_ENTER) submitFilter();
  else if (keyCode == KeyEvent.VK_ESCAPE) clearFilter();
  else if ((keyCode == KeyEvent.VK_CONTEXT_MENU) ||
      ((keyCode == KeyEvent.VK_F10) &&
      (e.getModifiers() == InputEvent.SHIFT_MASK))) showPopup();
}

代码示例来源:origin: leMaik/swing-material

@Override
protected void processKeyEvent(KeyEvent e) {
  super.processKeyEvent(e);
  floatingLabel.update();
  line.update();
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu

protected void processKeyEvent(KeyEvent _evt) {
 if (_evt.getID() == KeyEvent.KEY_TYPED) if (!isCharValid(_evt.getKeyChar())) return;
 super.setForeground(textFg_);
 super.processKeyEvent(_evt);
}

代码示例来源:origin: com.jidesoft/jide-oss

@Override
  public void processKeyEvent(KeyEvent e) {
    int keyCode = e.getKeyCode();
    if (keyCode == KeyEvent.VK_BACK_SPACE && getDocument().getLength() == 0) {
      e.consume();
      return;
    }
    final boolean isNavigationKey = isNavigationKey(e);
    if (isDeactivateKey(e) && !isNavigationKey) {
      hidePopup();
      if (keyCode == KeyEvent.VK_ESCAPE)
        e.consume();
      return;
    }
    super.processKeyEvent(e);
    if (keyCode == KeyEvent.VK_BACK_SPACE || isNavigationKey)
      e.consume();
    if (isSelectAllKey(e)) {
      e.consume();
    }
  }
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

public void processKeyEvent(KeyEvent ke) {
  if (!isShowing()) {
    super.processKeyEvent(ke);
    return;
  }
  //override the default handling so that
  //the parent will never receive the escape key and
  //close a modal dialog
  if (ke.getKeyCode() == ke.VK_ESCAPE) {
    //The focus request will hide the field without focus getting
    //lost to somewhere else in the main window first.
    BaseTable.this.changeSelection(selectionBeforeLastShow, 0, false, false);
    BaseTable.this.requestFocus();
    ke.consume();
  } else if ((ke.getKeyCode() == ke.VK_UP) && (ke.getID() == ke.KEY_PRESSED)) {
    reverseSearch(getText());
  } else if ((ke.getKeyCode() == ke.VK_DOWN) && (ke.getID() == ke.KEY_PRESSED)) {
    forwardSearch(getText());
  } else {
    super.processKeyEvent(ke);
    if ((ke.getKeyCode() != ke.VK_UP) && (ke.getKeyCode() != ke.VK_DOWN)) {
      processSearchText(getText());
    }
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

public void processKeyEvent(KeyEvent ke) {
  if (!isShowing()) {
    super.processKeyEvent(ke);
    return;
  }
  //override the default handling so that
  //the parent will never receive the escape key and
  //close a modal dialog
  if (ke.getKeyCode() == ke.VK_ESCAPE) {
    //The focus request will hide the field without focus getting
    //lost to somewhere else in the main window first.
    BaseTable.this.changeSelection (selectionBeforeLastShow, 0, false, false);
    BaseTable.this.requestFocus();
    ke.consume();
  } else if (ke.getKeyCode() == ke.VK_UP && ke.getID() == ke.KEY_PRESSED) {
    reverseSearch(getText());
  } else if (ke.getKeyCode() == ke.VK_DOWN && ke.getID() == ke.KEY_PRESSED) {
    forwardSearch(getText());
  } else {
    super.processKeyEvent(ke);
    if (ke.getKeyCode() != ke.VK_UP && ke.getKeyCode() != ke.VK_DOWN) {
      processSearchText(getText());
    }
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

public void processKeyEvent(KeyEvent ke) {
  if (!isShowing()) {
    super.processKeyEvent(ke);
    return;
  }
  //override the default handling so that
  //the parent will never receive the escape key and
  //close a modal dialog
  if (ke.getKeyCode() == ke.VK_ESCAPE) {
    //The focus request will hide the field without focus getting
    //lost to somewhere else in the main window first.
    BaseTable.this.changeSelection (selectionBeforeLastShow, 0, false, false);
    BaseTable.this.requestFocus();
    ke.consume();
  } else if (ke.getKeyCode() == ke.VK_UP && ke.getID() == ke.KEY_PRESSED) {
    reverseSearch(getText());
  } else if (ke.getKeyCode() == ke.VK_DOWN && ke.getID() == ke.KEY_PRESSED) {
    forwardSearch(getText());
  } else {
    super.processKeyEvent(ke);
    if (ke.getKeyCode() != ke.VK_UP && ke.getKeyCode() != ke.VK_DOWN) {
      processSearchText(getText());
    }
  }
}

相关文章

JTextField类方法