code: public boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed) {
          if (ks == KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0) || ks == KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)) {
              return false;
          }
          return super.processKeyBinding(ks, e, condition, pressed);
      }
docs: Overiding this method prevents the TextField from intercepting the Enter
  Key when focus is not on it. This allows default buttons to function.
  This should be removed when Swing fixes their bug.
  
  @see javax.swing.JComponent#processKeyBinding(javax.swing.KeyStroke,
  java.awt.event.KeyEvent, int, boolean)