Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javafx 2 获取hbox/vbox中的节点位置_Javafx 2_Javafx - Fatal编程技术网

Javafx 2 获取hbox/vbox中的节点位置

Javafx 2 获取hbox/vbox中的节点位置,javafx-2,javafx,Javafx 2,Javafx,我正在尝试在控制器类中获取TextField的X,Y位置,我将其包装在一个hbox中,并附上一个标签和ComboBox 我知道通常通过调用layoutX()和layoutY()可以得到X,Y,但它返回了0 下面是fxml代码 <HBox alignment="CENTER_LEFT" padding="$x1" prefHeight="-1.0" prefWidth="-1.0" spacing="10.0"> <children> <Lab

我正在尝试在控制器类中获取TextField的X,Y位置,我将其包装在一个hbox中,并附上一个标签和ComboBox

我知道通常通过调用
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>`

`

我甚至尝试了get
addFieldName.getWidth()
,它也返回0。

节点的属性很少,可以让您获得其边界的详细信息

比如
getBoundsInLocal()
getBoundsInParent()


请参阅以供参考。

是否已解决此问题。我被困在同一个问题上。布局,boundinparent,不起作用。