2

如果我尝试在 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

...这不适用于 Scene Builder,当我尝试打开 fxml 文件时,我检索到一条错误消息(见下文)。

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
4

2 回答 2

1
于 2016-05-01T14:16:17.623 回答
0

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

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

于 2015-01-31T21:58:33.223 回答