gpt4 book ai didi

layout - 节点之间的 BorderPane 间距

转载 作者:行者123 更新时间:2023-12-04 01:09:14 26 4
gpt4 key购买 nike

是否可以在 BorderPane 上设置节点之间的间距? ? Swing 等效项将是 BorderLayout 上的 hgap 和 vgap .

我在文档中没有找到任何内容,我能想到的唯一可行的解​​决方法是有选择地在子节点上设置边距以复制效果。

最佳答案

Insets insets = new Insets(10);
BorderPane bp = new BorderPane();

Node topNode = new Label("TOP");
bp.setTop(topNode);
BorderPane.setMargin(topNode, insets);

Node centerNode = new Label("CENTER");
bp.setCenter(centerNode);
BorderPane.setMargin(centerNode, insets);

Node bottomNode = new Label("BOTTOM");
bp.setBottom(bottomNode);
BorderPane.setMargin(bottomNode, insets);
请注意:这将在顶部和中心之间放置 20(距顶部 10 和距中心 10)的间距。
中心和底部之间的间距类似。
文档

public static void setMargin(Node child, Insets value)

Sets the margin for the child when contained by a border pane. If set, the border pane will lay it out with the margin space around it. Setting the value to null will remove the constraint.

关于layout - 节点之间的 BorderPane 间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32077140/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com