JavaFX: FXML: How to make the child to extend its size to fit the parent pane?

前端 未结 6 1300
广开言路
广开言路 2020-12-14 08:18

I have managed to load a child fxml(sub UI) under a parent fxml (mainMenu UI). I have created an AnchorPane with id \"mainContent\". This pane is bound to 4 sides and change

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 08:41

    If you set the static methods setTopAnchor( child, value ), setBottomAnchor( ... ), setLeftAnchor( ... ), setRightAnchor( ... ) of class AnchorPane to 0.0, the child Node will get stretched to the full extend of the parent AnchorPane.

    Documentation Link: AnchorPane

    edit: in the documentation link you can also see how you can set these values in your java code.

    FXML example:

    
    
    
    

提交回复
热议问题