由于某种原因,当我使用getWindow()。getWidth()从场景中请求screenWidth时,它返回的宽度大于实际宽度。有人知道为什么吗?
public Pane getStackPane(double screenWidht, double screenHeight) {
double width;
double height;
double d;
for (int i = 0; i < panes.size(); i++) {
d = (double)i;
width = screenWidht - d * (screenWidht / 6);
height = screenHeight - d * (screenHeight / 6);
panes.get(i).setPrefSize(width, height);
panes.get(i).setMinHeight(height);
panes.get(i).setMinWidth(width);
panes.get(i).setMaxHeight(height);
panes.get(i).setMaxWidth(width);
}
StackPane stackpane = new StackPane();
stackpane.getChildren().addAll(panes);
return stackpane;
}
示例显示在图片中。