是否有可能以下列方式使用玻璃板?将两个组件(img/label)对齐到左侧,然后在右侧设置多个按钮。示例:
+----------------------------------------------------------------+
| +------+ +----------+ +-----+ +-----+ |
| | Img | | Text... | | btn | | btn | |
| +------+ +----------+ +-----+ +-----+ |
+----------------------------------------------------------------+为了设计/使用方便,我增加了按钮,但我撞到了砖墙。我不想改变‘控制面板’。
如果没有,可以用css (浮子)来模拟吗?
谢谢
发布于 2016-01-19 09:13:47
FlowPane可以设置页边距。这里是一个示例,演示了如何计算页边距的宽度,从而使按钮正确对齐。
scene.widthProperty().addListener( ( observable, oldWidth, newWidth ) ->
{
final double spacerMargin = newWidth.doubleValue()
- scene.getRoot().getChildrenUnmodifiable().stream().mapToDouble( node -> node.getLayoutBounds().getWidth() ).sum();
FlowPane.clearConstraints( btn3 );
FlowPane.setMargin( btn3, new Insets( 0, 0, 0, spacerMargin ) );
} );基本上,从场景的宽度中减去FlowPane的所有子元素的宽度。
发布于 2016-01-18 16:02:18
是的!
myFlow.add(griddy); // this gridlayout contains img and text
myFlowcontainer.add(Box.createRigidArea(new Dimension(5,0))); // Creating a space between.
The actual size will be defined by you
myFlow.add(griddy2); // The other element with the btn btn(这应该能达成交易;)
https://stackoverflow.com/questions/34858706
复制相似问题