Fullscreen stage is not working properly in JavaFX 2.1?

后端 未结 2 856
伪装坚强ぢ
伪装坚强ぢ 2021-01-14 16:05

The first stage that I load it always open properly as fullscreen.

stage.setFullScreen(true);
stage.setScene(login_scene); 

But when I chan

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-14 17:07

    If I am right to know your concern then You should use your primary stage as static or you can make it available to other controller by making getters and setters. So to get same stage to load other fxmls you can set it to when you are loading a fxml and also make sure that do not create another scene. Because due to new scene you actual content resized. So you can use this

    In Main.java:

    YourController objYourController  = loader.getController();
    objYourController.setDialogStage(primaryStage);
    

    In YourController.java:

    public void setMystage(Stage primaryStage) {
        this.primaryStage= primaryStage;
    }
    
    //To load another FXML
    Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));
    primaryStage.getScene().setRoot(rootLayout);
    

    Hope it will help you.

提交回复
热议问题