0

I have two fxml files which represent 2 windows : a login window and the app window. After clicking on sign up, the second window appears.

My problem is that the second window has the same size as the login window. The preferred size of my app window is ignored.

top of app.fxml :

<BorderPane fx:id="root" prefHeight="800.0" prefWidth="1000.0" 
      xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2"
      fx:controller="...">
...
</BorderPane>

The code to load the app window :

FXMLLoader loader = new FXMLLoader(getClass().getResource("/main/resources/fxml/app.fxml"));
mainWindowController = loader.getController();
scene.setRoot((Parent) loader.load());

So my question is how to load app.fxml in the scene without ignoring prefHeight and prefWidth of app.fxml ?

Thanks for your help.

4

1 回答 1

2

线后

scene.setRoot((Parent) loader.load());

称呼

scene.getWindow().sizeToScene();
于 2013-08-21T16:59:02.930 回答