Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expand a GridPane to max width and height

is it possible to expand a grid pane to max width and height?

i have the following:

<fx:root type="javafx.scene.layout.AnchorPane" xmlns:fx="http://javafx.com/fxml"
         stylesheets="view/Style.css">
    <children>
        <GridPane xmlns:fx="http://javafx.com/fxml"
                  AnchorPane.topAnchor="0.0" AnchorPane.bottomAnchor="128.0"
                  AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
                  hgap="10" vgap="10">
            <!--anything-->
        </GridPane>
    </children>
</fx:root>

and i'd like to expand the grid pane to the limits determined by the anchor pane (so whole screen except the lower part)

like image 425
user1090694 Avatar asked Feb 26 '13 11:02

user1090694


2 Answers

Try set maxHeight and maxWidth properties of GridPane.

maxHeight="Infinity" maxWidth="Infinity"

And childrens of GridPane should contain

GridPane.hgrow="always" GridPane.vgrow="always"
like image 135
Qwertovsky Avatar answered Nov 17 '22 10:11

Qwertovsky


If you are using JavaFX directly without fxml. The code is:

GridPane.setHgrow(childElementOfGridPane, Priority.ALWAYS);
GridPane.setVgrow(childElementOfGridPane, Priority.ALWAYS);
like image 36
Johannes Avatar answered Nov 17 '22 09:11

Johannes