从Javafx2.2迁移到Javafx8

Jay*_*ani 3 fxml javafx-8

我正在尝试将Javafx2.2应用程序迁移到Javafx8.我在使用嵌套时遇到以下问题FXML:

javafx.fxml.LoadException: Root hasn't been set.
Use method setRoot() before load.
Run Code Online (Sandbox Code Playgroud)

FXML文件:

<fx:root type="javafx.scene.layout.VBox" 
         xmlns:fx="http://javafx.com/fxml"
         xmlns="http://javafx.com/javafx/8"
         fx:controller="com.ui.TestController">
    <TextField fx:id="textField"/>
    <Button text="Click Me"/>
</fx:root>
Run Code Online (Sandbox Code Playgroud)

码:

FXMLLoader loader = new FXMLLoader();
loader.setResources(bundle);
InputStream in = Main.class.getClassLoader().getResourceAsStream(fxml);
loader.setBuilderFactory(new JavaFXBuilderFactory());
loader.setLocation(Main.class.getResource(fxml));
Node page = null;
try {
    page = (Node) loader.load(in);
} catch (IOException e) {
    logger.error("{}", e);
} finally {
    try {
        in.close();
    } catch (IOException e) {
        logger.error("{}", e);
    }
}
Run Code Online (Sandbox Code Playgroud)

我需要page在另一个节点中设置节点BorderPane.center.它适用于Javafx2.2.我在这里缺少什么?任何帮助,将不胜感激.

Jay*_*ani 5

使用<VBox></VBox>而不是<fx:root type="javafx.scene.layout.VBox"></fx:root>已修复此问题,至少为Javafx构建b121.