Chirag Kamat
Chirag Kamat

Reputation: 109

How to change the StageStyle in JavaFX

is it possible to change the StageStyle from `StageStyle.UNIFIED' to 'StageStyle.UTILITY' when the stage is already Active

my code for stage creation :

Stage PrimaryStage= new Stage(StageStyle.UTILITY);
        Parent root = FXMLLoader.load(getClass().getResource("/InterfacePack/User_Management_Login.fxml"));
        Scene scene = new Scene(root);
        stage.setTitle("-: Login :-");
        PrimaryStage.setScene(scene);
        PrimaryStage.show();

i want to change the stagestyle in following code :

  stage = (Stage) LoginButton.getScene().getWindow();
                Parent root = null;
                try {
                    root = FXMLLoader.load(getClass().getResource("/InterfacePack/User_Management_fx.fxml"));
                } catch (IOException ex) {
                    Logger.getLogger(User_Management_LoginController.class.getName()).log(Level.SEVERE, null, ex);
                }
                Scene scene = new Scene(root);
                Toolkit kit = Toolkit.getDefaultToolkit();
                Dimension dim = kit.getScreenSize();
                stage.setHeight(dim.getHeight());
                stage.setWidth(dim.getWidth());
                stage.setResizable(false);
                stage.setMaximized(true);
                stage.setScene(scene);
                stage.setTitle("Automation Of Real Estate Construction Company");
                stage.show();

How should i Implement it..?? Please Help..

Upvotes: 0

Views: 1090

Answers (1)

ItachiUchiha
ItachiUchiha

Reputation: 36722

No, you can't do change the style of a stage when it is already Active / Showing

From the docs

The style must be initialized before the stage is made visible.

You can read the section on Styles from the Stage API Documentation

Upvotes: 2

Related Questions