簡體   English   中英

無法在BorderPane中定位CENTER

[英]Unable to Pos.CENTER in BorderPane

    BorderPane root = new BorderPane();

    Button chooseFile = new Button("chooseFile");
    TextField fileLocation = new TextField("C:/");
    Button makeGrid = new Button("Solve");
    HBox fileLoad = new HBox(chooseFile, fileLocation, makeGrid);

    root.setTop(lastfil);
    BorderPane.setAlignment(root, Pos.TOP_CENTER);
    BorderPane.setMargin(root, new Insets(12,12,12,12));
    root.setPrefSize(500, 500);

我對此有一些問題,我希望prefSize為500 x 500,並在文件加載器的頂部居中,但它不這樣做。 它是頂部,但我無法將其移到頂部的中央。 有什么明顯的我做錯了嗎?

BorderPane設置子節點的對齊方式和邊距。

BorderPane.setAlignment(節點子節點,Pos值)

BorderPane.setMargin(節點子節點,插入值)

因此,將Borderpane'root'替換為子節點'fileLoad':

BorderPane.setAlignment(fileLoad, Pos.TOP_CENTER);
BorderPane.setMargin(fileLoad, new Insets(12,12,12,12));

還將子級HBox對齊方式設置為:

fileLoad.setAlignment(Pos.CENTER);

請參閱Class BorderPane類以了解更多信息。

暫無
暫無

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

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