I set the height and the width of the stage before the start function.
Public void start( Stage primaryStage){
primaryStage.setHeight(500);
primaryStage.setWigth(500);
...
System.out.println(primaryStage.getHeight() +" - "+ primaryStage.getWidth());
...
primaryStage.setScene(scene);
primaryStage.show();
}
If you write "primaryStage.getHeight()" after "primaryStage.setHeight(500);"
the result will be "NaN"
Thank you, hope I help you