How to dynamically change scene height in JavaFx
1 answer
Use stage.sizeToScene () to resize the stage to whatever the current preferred size of this root is.
stage.setScene(new Scene(someContent));
stage.show();
....
stage.getScene().setRoot(someNewContent));
stage.sizeToScene();
You can also just call stage.setWidth () or stage.setHeight () if you don't need the automatic sizing behavior sizeToScene()
.
You can use the Timeline to animate the resizing of the scene if you need to.
+4
source to share