我刚刚在另一个平台上找到答案:
这很简单
FlowPane layout=new FlowPane();
layout.prefWidthProperty().bind(stage.widthProperty());
layout.prefHeightProperty().bind(stage.heightProperty());
Run Code Online (Sandbox Code Playgroud)
小智 6
如果你想自动调整大小,你应该做这样的事情
private BorderPane root;
@Override
public void start(Stage stage) throws Exception
{
root = new BorderPane();
//ROOT SHOULD BE ONE OF THE LAYOUTS : BorderPane, HBox, VBox, StackPane,
//GridPane, FlowPane
scene = new Scene(root, 500, 500);
stage.setScene(scene);
stage.show();
root.setCenter(new Label("sample label"));
}
Run Code Online (Sandbox Code Playgroud)
我只尝试过BorderPane并且它有效.此外,如果要创建自定义组件,您的类应扩展其中一个布局.如果组件扩展窗格或组,则自动调整大小将不起作用
我想这会对你有所帮助.
最好的问候桑德罗
| 归档时间: |
|
| 查看次数: |
7682 次 |
| 最近记录: |