簡體   English   中英

JavaFX FXML中心BorderPane底部

[英]JavaFX FXML Center BorderPane bottom

我有一個Button ,我想將其放在BorderPane的底部並將其居中。 我想用FXML實現。

這是我的BorderPane的底部:

        <bottom>
            <Button>
                <text>
                    Center this button
                </text>
            </Button>
        </bottom>

完整的FXML (無導入):

<BorderPane id="BorderPane" xmlns:fx="http://javafx.com/fxml/1">
        <top>
            <HBox>
                <BorderPane.margin>
                    <Insets left="15" right="15" top="15"/>
                </BorderPane.margin>
                <spacing>
                    5
                </spacing>
                <Label>
                    <padding>
                        <Insets top="5" right="5"/>
                    </padding>
                    <text>
                        Y-Axis:
                    </text>
                </Label>
                <TextField>
                    <text>
                        10
                    </text>
                </TextField>

                <Label>
                    <padding>
                        <Insets top="5" left="15" right="5"/>
                    </padding>
                    <text>
                        X-Axis:
                    </text>
                </Label>
                <TextField>
                    <text>
                        10
                    </text>
                </TextField>
            </HBox>
        </top>

        <bottom>
            <Button>
                <text>
                    Center this button
                </text>
            </Button>
        </bottom>

結果:

在此處輸入圖片說明

是否有標簽可以用FXML實現? 還是我必須使用JAVA做到這一點? 謝謝。

使用BorderPane.alignment

<bottom>
    <Button BorderPane.alignment="CENTER">
        <text>
            Center this button
        </text>
    </Button>
</bottom>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM