If there are 3 files in a JavaFX project; an FXML file, a controller for the FXML, and an application class; how can the controller respond to a button click (which works pe
You can try like this too.
public void onBtnClick(ActionEvent event) {
try {
FXMLLoader loader = new FXMLLoader(getClass().getResource("login.fxml"));
Stage stage = (Stage) btn.getScene().getWindow();
Scene scene = new Scene(loader.load());
stage.setScene(scene);
}catch (IOException io){
io.printStackTrace();
}
}