How to call functions on the stage in JavaFX's controller file

后端 未结 6 1867
孤独总比滥情好
孤独总比滥情好 2021-01-02 05:08

I am using javafx along with fxml, so I use the controller for the real coding. I need to do a few operations on the stage, such as getting

6条回答
  •  轮回少年
    2021-01-02 05:43

    From your root Pane in the fxml file :

    @FXML
    Parent root
    

    You can get the stage from it by:

    Stage stage = (Stage) root.getScene().getWindow()
    

    You have a reference to your stage, you can do what you want.

提交回复
热议问题