JavaFX: Why does stage.setResizable(false) cause additional margins?

As already commented, this different behaviour of !/resizable smells like a bug (somebody might consider filing an issue ;-)

A shorter (than sizing manually) way around is to explicitly fit the stage to the scene:

primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.sizeToScene();

Just noticed that this works for jdk8, but not jdk7.

For convenience, a bug update: the original report filed by jewelsea was closed as a duplicate of (in new coordinates) https://bugs.openjdk.java.net/browse/JDK-8089008 - still open, commented to be win-only.


Although this is not explanation, it solves the problem:

@Override
public void start(final Stage primaryStage) throws Exception {
    final Dimension d = new Dimension(210, 110);
    final Rectangle rectangle = new Rectangle(d.width, d.height, Color.POWDERBLUE);
    final BorderPane pane = new BorderPane(rectangle);
    pane.maxWidth(d.height);
    pane.maxWidth(d.width);
    final Scene scene = new Scene(pane, d.width, d.height);
    primaryStage.setScene(scene);
    primaryStage.setResizable(false);
    primaryStage.setWidth(d.width);
    primaryStage.setHeight(d.height);
    primaryStage.show();
}

Key is setting width and height of the Stage at the right time.