我在包含行的 FXML 文件上有带有布局的自定义组件
<fx:root type="javafx.scene.layout.VBox" spacing="10.0" xmlns:fx="http://javafx.com/fxml">
我在 SceneBuilder 1.0 上创建了这个文件,但后来我尝试在 SceneBuilder 2.0 上打开这个文件我得到了异常
java.io.IOException: javafx.fxml.LoadException: Root hasn't been set. Use method setRoot() before load.
/Users/dmitrynelepov/Development/SogazGit/smpb/SMProjectBrownRelease/SMPBProxy/engine/fxml/component_daemon_viewer.fxml:14
还必须说明:在应用程序中,通过代码设置 root 可以很好地加载这个 fxml。
在官方教程(http://docs.oracle.com/javafx/2/fxml_get_started/custom_control.htm)中告诉:
<fx:root type="javafx.scene.layout.VBox" xmlns:fx="http://javafx.com/fxml">
<TextField fx:id="textField"/>
<Button text="Click Me" onAction="#doSomething"/>
</fx:root>
如您所见,Oracle 告诉:删除 NetBeans IDE 自动生成的 AnchorPane 标记。
但它不起作用。
更新
SceneBuilder 2.0 Build 7 - 问题仍然存在
JDK8 b117 - 问题仍然存在