Javafx SceneBuilder 2.0无法加载fxml

时间:2016-11-03 17:39:33

标签: java javafx fxml scenebuilder

SceneBuilder打开我的main.fxml时出现问题。当我运行项目时,一切正常,但我无法在SceneBuilder下修改。每次我想要添加到main.fxml时,我需要删除包含执行我想要的内容并在fxml中手动粘贴代码而不是SceneBuilder(不能包含在标签下?)。

main.fxml

  <Tab text="Details">
           <content>
              <ScrollPane prefHeight="200.0" prefWidth="200.0">
                 <content>
                    <fx:include fx:id="details" source="/view/tab/details.fxml" /> // line number 59
                 </content>
              </ScrollPane>
           </content>
      </Tab>

我的结构包

...
|---> view
      main.fxml
      |--> view.tab
           details.fxml
           ...

来自SceneBuilder的错误

java.io.IOException: javafx.fxml.LoadException: 
/C:/Users/Michal/Dropbox/workspace/Java/Feeder%20v%202.0/src/view/main.fxml:59
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:92)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:80)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMDocument.<init>(FXOMDocument.java:95)
at com.oracle.javafx.scenebuilder.kit.editor.EditorController.updateFxomDocument(EditorController.java:2370)
at com.oracle.javafx.scenebuilder.kit.editor.EditorController.setFxmlTextAndLocation(EditorController.java:655)
at com.oracle.javafx.scenebuilder.app.DocumentWindowController.loadFromFile(DocumentWindowController.java:386)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.performOpenFiles(SceneBuilderApp.java:579)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.handleOpenFilesAction(SceneBuilderApp.java:447)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.handleLaunch(SceneBuilderApp.java:427)
at com.oracle.javafx.scenebuilder.app.AppPlatform.requestStartGeneric(AppPlatform.java:139)
at com.oracle.javafx.scenebuilder.app.AppPlatform.requestStart(AppPlatform.java:106)
at com.oracle.javafx.scenebuilder.app.SceneBuilderApp.start(SceneBuilderApp.java:371)
at com.sun.javafx.application.LauncherImpl$8.run(LauncherImpl.java:837)
at com.sun.javafx.application.PlatformImpl$7.run(PlatformImpl.java:335)
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:301)
at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:298)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$6.run(PlatformImpl.java:298)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
at java.lang.Thread.run(Thread.java:744)
Caused by: javafx.fxml.LoadException: 
/C:/Users/Michal/Dropbox/workspace/Java/Feeder%20v%202.0/src/view/main.fxml:59
at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2617)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2595)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2425)
at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.load(FXOMLoader.java:89)
... 22 more
Caused by: java.io.FileNotFoundException: view\tab\details.fxml (System nie może odnaleźć określonej ścieżki)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:131)
    at java.io.FileInputStream.<init>(FileInputStream.java:87)
    at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
    at java.net.URL.openStream(URL.java:1038)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2440)
    at javafx.fxml.FXMLLoader.access$2500(FXMLLoader.java:104)
    at javafx.fxml.FXMLLoader$IncludeElement.constructValue(FXMLLoader.java:1144)
    at javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:740)
    at javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2723)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2527)
    ... 24 more

1 个答案:

答案 0 :(得分:1)

不再支持SceneBuilder 2.0。一家名为Gluon的公司正在维护它。我使用Gluon的版本在<fx:include>标签上取得了成功。试试吧:

http://gluonhq.com/labs/scene-builder/