此代码将创建一个300x300大的3d场景.调整包含窗口/舞台大小时,视口不会调整大小.
Parent没有任何width或height属性.如何调整Parent和/或SubScene更改窗口大小的大小?
将它绑定到父级
SubScene subscene = new SubScene(root, 1024, 768, true, null);
subscene.setFill(Color.GREY);
subscene.setCamera(camera);
StackPane stackPane = new StackPane();
stackPane.getChildren().add(subscene);
subscene.heightProperty().bind(stackPane.heightProperty());
subscene.widthProperty().bind(stackPane.widthProperty());
Run Code Online (Sandbox Code Playgroud)
小智 6
我发现将 SubScene 对象的托管属性设置为 false 也很重要。
subscene.setManaged(false);
Run Code Online (Sandbox Code Playgroud)
这样,SubScene 对象的大小不会影响其父 StackPane 对象的大小,并且在减小 StackPane 对象的大小时调整大小也将起作用。
| 归档时间: |
|
| 查看次数: |
2930 次 |
| 最近记录: |