2016-04-27 14 views
1

ラベルとボタン(およびテキストフィールド)を水平レイアウトに配置するのが好きです。これは動作しますが、ベースラインはアラインされていません。それを修正するには?ベースライン時にラベルとボタンを揃える方法は?

Baselines are unaligned

期待される結果は、赤線(各コントロールのベースライン)が同じ高さにあることです。

これは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> 

答えて

4

は値"BASELINE_LEFT"HBoxに整列属性を追加します。

<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> 

enter image description here

関連する問題