JavaFX FXML HBox左右对齐
我正在尝试对齐HBox的子节点(即网格窗格),以便一个节点与HBox的左侧对齐,另一个与右侧对齐。我怎样才能做到这一点 这就是我得到的: 这就是我想要实现的目标: 这是我目前拥有的代码:JavaFX FXML HBox左右对齐,javafx,alignment,hbox,Javafx,Alignment,Hbox,我正在尝试对齐HBox的子节点(即网格窗格),以便一个节点与HBox的左侧对齐,另一个与右侧对齐。我怎样才能做到这一点 这就是我得到的: 这就是我想要实现的目标: 这是我目前拥有的代码: <TextArea/> <HBox spacing="10"> <Button text="Attack"/> <Button text="Spells"/> <Button text="Inventory"/> &
<TextArea/>
<HBox spacing="10">
<Button text="Attack"/>
<Button text="Spells"/>
<Button text="Inventory"/>
<Button text="Run"/>
</HBox>
<HBox alignment="center_left" spacing="10">
<GridPane hgap="10" vgap="5" >
<Label text="Name: " GridPane.columnIndex="0" GridPane.rowIndex="0"/>
<Text text="${controller.battle.player.name}" GridPane.columnIndex="1" GridPane.rowIndex="0"/>
<Label text="Health: " GridPane.columnIndex="0" GridPane.rowIndex="1"/>
<Text text="${controller.battle.player.hubHealth}" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<Label text="Level: " GridPane.columnIndex="0" GridPane.rowIndex="2"/>
<Text text="${controller.battle.player.hubLevel}" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<Label text="Experience: " GridPane.columnIndex="0" GridPane.rowIndex="3"/>
<Text text="${controller.battle.player.hubExperience}" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
</GridPane>
<HBox alignment="center_right">
<GridPane hgap="10" vgap="5" >
<Label text="Name: " GridPane.columnIndex="0" GridPane.rowIndex="0"/>
<Text text="${controller.battle.enemy.name}" GridPane.columnIndex="1" GridPane.rowIndex="0"/>
<Label text="Health: " GridPane.columnIndex="0" GridPane.rowIndex="1"/>
<Text text="${controller.battle.enemy.hubHealth}" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
<Label text="Level: " GridPane.columnIndex="0" GridPane.rowIndex="2"/>
<Text text="${controller.battle.enemy.hubLevel}" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
<Label text="Experience: " GridPane.columnIndex="0" GridPane.rowIndex="3"/>
<Text text="${controller.battle.enemy.hubExperience}" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
</GridPane>
</HBox>
</HBox>
我无法将您的FXML
加载到SceneBuilder
中。请在HBox中的两个当前节点之间放置另一个节点。将新节点设置为HBox.AlwaysGrow
。同意Sedrick。。。尝试在和设置Hgrow之间添加一个窗格。始终HBox.Hgrow=“始终”
awooms!这就成功了。非常感谢。我无法将您的FXML
加载到SceneBuilder
中。请在HBox中当前两个节点之间放置另一个节点。将新节点设置为HBox.AlwaysGrow
。同意Sedrick。。。尝试在和设置Hgrow之间添加一个窗格。始终HBox.Hgrow=“始终”
awooms!这就成功了。非常感谢。