可以在BorderPane上设置节点之间的间距吗?在BorderLayout上,Swing的等价物是hgap和vgap。
我在文档中没有找到任何东西,我能想到的唯一可行的解决方法是有选择地在子节点上设置边距,以复制效果。
发布于 2017-08-31 21:00:47
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个)。中心和底部之间的间距类似。
文档
公共静态空setMargin(Node子节点,插入值)
当边框窗格包含子项时,设置子项的边距。如果设置了边框窗格,边框窗格将在边框周围留出边距。将该值设置为null将删除约束。
发布于 2017-01-07 19:06:05
可以设置填充:
在JFX中:
<BorderPane>
<padding>
<Insets top="10" right="10" bottom="10" left="10"/>
</padding>
</BorderPane>在代码中:
@FXML
private BorderPane borderPane;
...
this.borderPane.setPadding(new Insets(10, 10, 10, 10));https://stackoverflow.com/questions/32077140
复制相似问题