1

I'm trying to align the child nodes of a HBox (which are gridpanes) so that one node is aligned to the left of the HBox and the other to the right. How can i achieve this?

This is what I'm getting: What I'm getting

This is what I want to achieve: What I want to achieve

This is the code I currently have:

<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>
rob8989
  • 81
  • 3
  • 11

0 Answers0