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

前端 未结 3 1729
情深已故
情深已故 2020-12-05 00:53

This small JavaFX test application

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.sce         


        
3条回答
  •  心在旅途
    2020-12-05 01:24

    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.

提交回复
热议问题