获取横向盒/ VBOX内节点位置

问题描述 投票:0回答:1

我试图让X,在控制类一个TextField我有一个标签,和ComboBox一起包裹在一个盒子里的Y位置。

我通常知道你可以通过调用layoutX()layoutY()获得X,Y但它返回0。

下面是FXML码

<HBox alignment="CENTER_LEFT" padding="$x1" prefHeight="-1.0" prefWidth="-1.0" spacing="10.0">
    <children>
        <Label maxWidth="-Infinity" minWidth="-Infinity" prefWidth="105.0" text="Add a Field:" />
        <TextField fx:id="addFieldName" prefWidth="200.0" promptText="Field Name" />
        <ComboBox fx:id="addFieldTypeComboBox" prefWidth="180.0" promptText="Choose a field type...">
          <items>
            <FXCollections fx:factory="observableArrayList">
              <String fx:value="Item 1" />
              <String fx:value="Item 2" />
              <String fx:value="Item 3" />
            </FXCollections>
          </items>
        </ComboBox>
        <Button fx:id="addFieldButton" mnemonicParsing="false" onAction="#handleAddFieldButtonAction" text="Add" />
    </children>
</HBox>`

我甚至尝试获取addFieldName.getWidth()并返回0为好。

javafx-2 javafx
1个回答
0
投票

还有,它可以让你获得其边界的细节Node的一些属性。

getBoundsInLocal()getBoundsInParent();

getBoundsInLocal以供参考。

© www.soinside.com 2019 - 2024. All rights reserved.