gpt4 book ai didi

javafx - 如何在 JavaFX 中将工具栏的项目向右对齐

转载 作者:行者123 更新时间:2023-12-01 11:40:07 25 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





How to right align a button in Java FX toolbar

(5 个回答)


4年前关闭。




如何将工具栏的项目向右对齐?
所有对齐设置似乎都不起作用。

我正在使用布局设计器。

请帮忙

enter image description here

<BorderPane fx:controller="vmanager.ui.Controller" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0"
prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<top>
<ToolBar prefWidth="200.0" BorderPane.alignment="CENTER_RIGHT">
<items>
<Button alignment="CENTER_RIGHT" mnemonicParsing="false" text="_"/>
<Button mnemonicParsing="false"/>
<Button mnemonicParsing="false" text="X" onAction="#close"/>
</items>
</ToolBar>
</top>

最佳答案

这是可行的 AnchorPane而不是工具栏:

<BorderPane id="BorderPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml">
<top>
<AnchorPane prefHeight="50.0">
<children>
<Button layoutY="14.0" mnemonicParsing="false" text="Button" AnchorPane.rightAnchor="14.0" />
<Button layoutY="15.0" mnemonicParsing="false" text="Button" AnchorPane.rightAnchor="70.0" />
<Label layoutY="18.0" prefWidth="449.0" text="Label" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="140.0" />
</children>
</AnchorPane>
</top>
</BorderPane>

我还添加了“窗口标题”标签。您可以设置 AnchorPane 的样式但是你以后喜欢,如果这实现了你想要的布局行为。

关于javafx - 如何在 JavaFX 中将工具栏的项目向右对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22096520/

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