codice:
textField.addKeyListener(new  KeyAdapter() {
   public void keyTyped(KeyEvent e) {
       if (e.getKeyCode() == KeyEvent.VK_ENTER) {
          loginButton.doClick();
       }
   }
}});