2 回答
TA贡献1807条经验 获得超9个赞
问题不是 的属性/布局约束,而是不允许增长到比首选宽度 ( ) 更宽MenuButton的事实。HBox346.0
将 的值更改maxWidth为USE_COMPUTED_SIZE(= -1)。或者,只需将属性删除为恰好为的默认值USE_COMPUTED_SIZE。
这允许HBox增长到SplitPane防止较小尺寸HBox水平居中的尺寸。
<SplitPane dividerPositions="0.5" orientation="VERTICAL" prefHeight="200.0" prefWidth="342.0" AnchorPane.bottomAnchor="363.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<items>
<HBox maxHeight="-Infinity" prefHeight="46.0" prefWidth="346.0"> <!-- removed maxWidth here -->
<children>
<MenuButton alignment="TOP_LEFT" mnemonicParsing="false" prefHeight="46.0" prefWidth="56.0" HBox.hgrow="ALWAYS">
...
</MenuButton>
</children>
</HBox>
...
</items>
</SplitPane>
TA贡献1860条经验 获得超9个赞
我已阅读您的问题并希望您查找 MenuButton 的对齐属性。或者您可以使用边框窗格以四种方式对齐您的组件。
1) 顶部,2) 底部,3) 左侧,4) 右侧
添加回答
举报