0

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..

Chirag Kamat
  • 89
  • 1
  • 10
  • 1
    You should close the existing stage and open a new one, if you want a different `StageStyle` – James_D Apr 16 '15 at 19:06
  • possible duplicate of [java fx java.lang.IllegalStateException (Stage)](http://stackoverflow.com/questions/27069384/java-fx-java-lang-illegalstateexception-stage) – Elltz Apr 17 '15 at 09:14

1 Answers1

2

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

ItachiUchiha
  • 36,135
  • 10
  • 122
  • 176