Exemplo n.º 1
0
 /** process the text field key event */
 protected void processKeyEvent(KeyEvent e) {
   int keyCode = e.getKeyCode();
   if (KeyEvent.getKeyText(keyCode).equals("Backspace")
       || KeyEvent.getKeyText(keyCode).equals("Enter")) {
     super.processKeyEvent(e);
   }
   if (49 <= keyCode && keyCode <= 58) {
     super.processKeyEvent(e);
     String mValue = KeyEvent.getKeyText(keyCode);
     this.setText(mValue);
   }
 }
    /**
     * I made this method public in order to be able to call it from the outside. This is needed for
     * delegating calls.
     */
    public void processKeyEvent(KeyEvent e) {
      int i = e.getKeyCode();
      if (i == KeyEvent.VK_BACK_SPACE && getDocument().getLength() == 0) {
        e.consume();
        return;
      }
      if (i == KeyEvent.VK_ENTER
          || i == KeyEvent.VK_ESCAPE
          || i == KeyEvent.VK_PAGE_UP
          || i == KeyEvent.VK_PAGE_DOWN
          || i == KeyEvent.VK_LEFT
          || i == KeyEvent.VK_RIGHT) {
        manageSearchPopup(null);
        if (i == KeyEvent.VK_ESCAPE) {
          e.consume();
        }
        return;
      }

      if (isUpDownHomeEnd(i)) {
        e.consume();
        return;
      }

      super.processKeyEvent(e);
      if (i == KeyEvent.VK_BACK_SPACE) {
        e.consume();
      }
    }
Exemplo n.º 3
0
 @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);
 }
Exemplo n.º 4
0
 @Override
 protected void processKeyEvent(KeyEvent e) {
   char c = e.getKeyChar();
   c = Character.toUpperCase(c);
   e.setKeyChar(c);
   int cd = e.getKeyCode();
   if ((c == KeyEvent.VK_DELETE) || (c == KeyEvent.VK_ENTER)) {
     super.processKeyEvent(e);
     return;
   }
   if ((c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_ESCAPE)) {
     super.processKeyEvent(e);
     return;
   }
   if (((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'F'))) {
     if (getCaretPosition() > 0) super.processKeyEvent(e);
     return;
   }
 }
Exemplo n.º 5
0
 public void processKeyEvent(KeyEvent ev) {
   char c = ev.getKeyChar();
   if ((Character.isLetter(c) && !ev.isAltDown()) || badchars.indexOf(c) > -1) {
     ev.consume();
     return;
   }
   if (c == '-' && getDocument().getLength() > 0) ev.consume();
   else {
     super.processKeyEvent(ev);
   }
 }
  @Override
  public void processKeyEvent(KeyEvent ev) {

    char c = ev.getKeyChar();
    if ((Character.isLetter(c) && !ev.isAltDown()) || badchars.indexOf(c) > -1) {
      ev.consume();
    } else {

      super.processKeyEvent(ev);

      String text = this.getText();
      if (!text.matches("^[0-9]*[\\.]?[0-9]?[0-9]?$")) {
        this.setText(text.substring(0, text.length() - 1));
      }
    }
  }
 public void processKeyEvent(KeyEvent e) {
   super.processKeyEvent(e);
 }