JavaFXshow another scence by click one button

    @FXML
    private void handleButtonAction(ActionEvent event) throws Exception {
        System.out.println("You clicked me!");
        label.setText("Hello World!");

        //aslo I want to show another scence

        //1.Get application stage
        Stage currentStage = (Stage) ((Node) event.getSource()).getScene().getWindow();
        //2.Create new scence from fxml
        Parent root = FXMLLoader.load(getClass().getResource("mainUI/mianUI.fxml"));

        Scene scene1 = new Scene(root);
        //3.Set new scence to the stage
        currentStage.setScene(scene1);
        //currentStage.show();
    }
原文地址:https://www.cnblogs.com/smartvessel/p/3108511.html