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

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

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

JTextField.processKeyBinding介绍

暂无

代码示例

代码示例来源:origin: com.haulmont.thirdparty/glazedlists

/**
   * We override this method to make it public so that it can be
   * called from {@link TableCellComboBox#processKeyBinding}.
   *
   * <p>This allows the keystroke which begins a table cell edit to
   * also contribute a character to this JTextField, thus mimicing
   * the behaviour of normal editable JTextField table cell editors.
   */
  @Override
  public boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
    return super.processKeyBinding(ks, e, condition, pressed);
  }
}

代码示例来源:origin: net.java.dev.glazedlists/glazedlists_java16

/**
   * We override this method to make it public so that it can be
   * called from {@link TableCellComboBox#processKeyBinding}.
   *
   * <p>This allows the keystroke which begins a table cell edit to
   * also contribute a character to this JTextField, thus mimicing
   * the behaviour of normal editable JTextField table cell editors.
   */
  @Override
  public boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
    return super.processKeyBinding(ks, e, condition, pressed);
  }
}

代码示例来源:origin: net.java.dev.glazedlists/glazedlists_java15

/**
   * We override this method to make it public so that it can be
   * called from {@link TableCellComboBox#processKeyBinding}.
   *
   * <p>This allows the keystroke which begins a table cell edit to
   * also contribute a character to this JTextField, thus mimicing
   * the behaviour of normal editable JTextField table cell editors.
   */
  @Override
  public boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
    return super.processKeyBinding(ks, e, condition, pressed);
  }
}

代码示例来源:origin: mikaelhg/openblocks

if (isNumber) {
  if (e.getKeyChar() == '-' && canProcessNegativeSign()) {
    return super.processKeyBinding(ks, e, condition, pressed);
      return super.processKeyBinding(ks, e, condition, pressed);
  for (char c : validChar) {
    if (e.getKeyChar() == c) {
      return super.processKeyBinding(ks, e, condition, pressed);
    return super.processKeyBinding(ks, e, condition, pressed);
  return super.processKeyBinding(ks, e, condition, pressed);

代码示例来源:origin: com.numdata/numdata-swing

@Override
  protected boolean processKeyBinding( final KeyStroke ks, final KeyEvent e, final int condition, final boolean pressed )
  {
    return super.processKeyBinding( ks, e, condition, pressed ) || ( e.getModifiers() == 0 || e.getModifiers() == InputEvent.SHIFT_MASK );
  }
}

代码示例来源:origin: mikaelhg/openblocks

@Override
  protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
    for (int validKeyCode : validKeyCodes) {
      if (e.getKeyCode() == validKeyCode) {
        return super.processKeyBinding(ks, e, condition, pressed);
      }
    }
    if (e.getKeyChar() == '.' && !this.getText().contains(".")) {
      return super.processKeyBinding(ks, e, condition, pressed);
    }
    if (e.getKeyChar() == '-' && (this.getCaretPosition() == 0 || this.getSelectionStart() == 0) && !this.getText().contains("-")) {
      return super.processKeyBinding(ks, e, condition, pressed);
    }
    if (Character.isDigit(e.getKeyChar())) {
      return super.processKeyBinding(ks, e, condition, pressed);
    } else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
      //evaluateTextFieldData();
      slider.requestFocus();
      return false;
    } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
      //evaluateTextFieldData();
      slider.requestFocus();
      return false;
    } else {
      return false;
    }
  }
}

代码示例来源:origin: org.tentackle/tentackle-swing

/**
 * {@inheritDoc}
 * <p>
 * Overridden:
 * Changes the nerving behaviour that pressing backspace at the end
 * of a selection clears the whole selection. Especially in autoselected
 * numeric fields its often necessary to overtype the last digits.
 * With this hack backspace simply clears the selection.
 */
@Override
protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
 if (pressed) {
  lastKeyEvent = e;   // remember last key event
  if (isAutoSelect() && ks.getKeyCode() == KeyEvent.VK_BACK_SPACE && ks.getModifiers() == 0) {
   int selStart = getSelectionStart();
   int selEnd   = getSelectionEnd();
   if (selEnd > selStart && getCaretPosition() == selEnd)  {
    // only if something selected and caret is at rightmost position of selection
    setSelectionStart(getSelectionEnd());   // clear selection, leave caret rightmost
   }
  }
  if (e.getKeyCode() == KeyEvent.VK_Z && e.getModifiers() == KeyEvent.CTRL_MASK) {
   // undo
   restoreSavedValue();
  }
 }
 return super.processKeyBinding(ks, e, condition, pressed);
}

相关文章

微信公众号

最新文章

更多

JTextField类方法