@FXML
private void login(Event event) throws IOException {
String userName = emailId.getText().trim();
String password = passwordId.getText().trim();
try {
if(isValidCredentials(userName, password)){
System.out.println("Login Successfull");
Parent mainScreen = FXMLLoader.load(getClass().getResource("MainPage.fxml"));
Scene mainScene = new Scene(mainScreen);
Stage mainStage = (Stage) ((Node) event.getSource()).getScene().getWindow();
mainStage.hide();
mainStage.setScene(mainScene);
mainStage.setTitle("Main Screen");
mainStage.show();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
This login method is being called on mouse click of login button. What i want is same method to be called when enter key is pressed on login page.