简体   繁体   中英

JavaFX FXML component fill parent - like alignParent in Android

A question asked a hundred times I know but nobody seems to know how to do this.

I have a BorderPane and want to put Canvas as bottom of the BorderPane. And I want the Canvas to fill the whole bottom. I don't want to hardcode any values. Is it even possible?

In Android I have something like alignParentTop etc. It's really unintuitive here in JavaFX.

<BorderPane fx:controller="pl.mg.checkers.controller.GameController"
            xmlns:fx="http://javafx.com/fxml">
    <top>
        <HBox>
            <Button fx:id="leaveButton" text="Leave"/> 
        </HBox>
    </top>
    <bottom>
        <Canvas fx:id="canvas"/>
    </bottom>
</BorderPane>

The problem is that Canvas is not resizable. See here for discussion and solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM