如何在基线对齐标签和按钮?

Ver*_*tex 2 layout javafx

我想在水平布局中放置一个标签和一个按钮(和一个文本字段)。这有效,但基线未对齐。如何解决?

基线未对齐

预期的结果是红线(每个控件的基线)处于相同的高度。

这是 FXML:

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.HBox?>

<HBox prefHeight="100.0" prefWidth="400.0" spacing="10.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <Label text="Label" />
      <Button mnemonicParsing="false" text="Button" />
      <TextField text="Lorem Ipsum" />
   </children>
</HBox>
Run Code Online (Sandbox Code Playgroud)

Jam*_*s_D 6

HBoxwith 值添加对齐属性"BASELINE_LEFT"

<HBox alignment="BASELINE_LEFT" prefHeight="100.0" prefWidth="400.0" spacing="10.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <Label text="Label" />
      <Button mnemonicParsing="false" text="Button" />
      <TextField text="Lorem Ipsum" />
   </children>
</HBox>
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明