txtStartDate.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { int keyChar = e.getKeyChar(); if(KeyEvent.VK_SPACE == keyChar) { e.consume(); } } });