@Override
    public void keyTyped(KeyEvent e) {
      if ((e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0) {
        return;
      }
      char c = e.getKeyChar();
      if (c == KeyEvent.VK_BACK_SPACE) {
        return;
      }
      // TODO: This statement used to check \\v and \\t as well, but it was causing VK_ENTER and
      // VK_TAB not to be accepted
      // as completing the menu which resulted in a painting exception. VK_TAB and VK_ENTER are
      // standard for completing
      // an autocompletion menu, see Eclipse and Scintilla/CodeBlocks.
      if (c == KeyEvent.VK_ENTER || c == KeyEvent.VK_TAB || c == KeyEvent.VK_SPACE) {
        apply(c);
        e.consume();
        dispose();
        return;
      }
      setSelectedText(String.valueOf(c));
      e.consume();
      reset();
    }