简体   繁体   English

JavaFX FXML组件填充父级-像Android中的alignParent

[英]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. 我有一个BorderPane,并希望将Canvas作为BorderPane的底部。 And I want the Canvas to fill the whole bottom. 我想让Canvas填满整个底部。 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. 在Android中,我有alignParentTop之类的东西。在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. 问题在于Canvas无法调整大小。 See here for discussion and solution. 参见此处的讨论和解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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