简体   繁体   中英

Setting VBox.vgrow on a child element of <fx:root> in JavaFX 8

I have the following .fxml file:

<fx:root type="javafx.scene.layout.VBox" xmlns:fx="javafx.com/fxml">
    <Pane VBox.vgrow="ALWAYS">
        <!-- ... -->
    </Pane>
</fx:root>

However, there is an error at VBox.vgrow="ALWAYS" , since <fx:root ... is not exactly a VBox. How can I do this in FXML (no Java)?


Edit: The error in my IDE shows "Attribute VBox.vgrow is not allowed here", and the error the Java application gives is "VBox.vgrow is not a valid attribute."

I had neglected to display all my imports of the .fxml file (which only had javafx.scene.layout.Pane ).

In order for that specific .fxml file to not give an error (see edit), the import javafx.scene.layout.VBox also had to be added, as VBox.* cannot be used on any element unless VBox is imported.

The correct .fxml file is:

<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<fx:root type="javafx.scene.layout.VBox" xmlns:fx="javafx.com/fxml">
    <Pane VBox.vgrow="ALWAYS">
        <!-- ... -->
    </Pane>
</fx:root>

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