JavaFX Scene Builder是否支持<fx:define>标记?</fx:define>

时间:2014-08-11 08:39:41

标签: javafx scenebuilder gluon

如果我尝试在fxml文件中使用fx:define标记,例如

<fx:define>
   <Tooltip fx:id="thetip" prefWidth="120" wrapText="true" text="Here's a tip of the day: prefWidth and wrapText attrs control the behavior of the tip."/>
</fx:define> 
<Button tooltip="${thetip}" text="Tip Button" />

(另见https://docs.oracle.com/javafx/2/api/javafx/fxml/doc-files/introduction_to_fxml.html#define_elements

...当我尝试打开fxml文件时,它无法与Scene Builder一起使用并检索错误消息(见下文)。

Scene Builder是否支持fx:define标记?

  • 如果是:我该如何正确使用它?

  • 如果否:我在哪里可以找到包含场景生成器支持(不)所有标签的列表?


java.io.IOException: javafx.fxml.LoadException: /D:/workspace/PowerTools/src/isi/power/tools/gui/manager/ScenarioManager.fxml:24
    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: 
/D:/workspace/PowerTools/src/isi/power/tools/gui/manager/ScenarioManager.fxml:24
    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.lang.NullPointerException
    at com.oracle.javafx.scenebuilder.kit.fxom.FXOMLoader.endElement(FXOMLoader.java:304)
    at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2842)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2532)
    ... 24 more

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

我注意到我的错误消息与定义不同,所以我将定义移动到文件的末尾,然后它似乎工作得很好。

更新:我现在似乎无法让它工作,但如果我删除fx:我可以让它工作:使用scenebuilder定义,编辑,然后把fx:define back