【问题标题】:Error when trying to move FXML files in e(fx)clipse尝试在 e(fx)clipse 中移动 FXML 文件时出错
【发布时间】:2015-01-28 21:32:32
【问题描述】:

我有这个代码和这个文件层次结构: 一切似乎都很好,但是我得到了这个错误日志:

java.lang.NullPointerException: Location is required.
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3201)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3169)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3142)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3118)
    at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3098)
    at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3091)
    at com.model.tomaszm.Main.start(Main.java:15)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
    at com.sun.javafx.application.LauncherImpl$$Lambda$51/1616271442.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
    at com.sun.javafx.application.PlatformImpl$$Lambda$45/1051754451.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
    at com.sun.javafx.application.PlatformImpl$$Lambda$47/1139233777.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
    at com.sun.javafx.application.PlatformImpl$$Lambda$46/1775282465.run(Unknown Source)
    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.lambda$null$141(WinApplication.java:102)
    at com.sun.glass.ui.win.WinApplication$$Lambda$37/1109371569.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)

可疑的是,当我尝试将 FXML 文件移动到 Eclipse 中的不同包时,我收到此消息对话框错误: 在“搜索进度轮询”期间发生内部错误。 线程访问无效

【问题讨论】:

  • 不确定 Eclipse 错误,但我认为您需要 getResource("/com/root/tomaszm/MainRoot.fxml"),具有您拥有的结构。 com.root.tomaszm 是包名,不是文件夹名。
  • 您的权利。现在可以了。

标签: eclipse javafx-8 efxclipse


【解决方案1】:

当 FXML 找不到您要加载的 FXML 文档时,它会引发该错误。

查看屏幕截图,这看起来应该可以帮助您克服遇到的错误:

Parent root = 
FXMLLoader.load(getClass().getResource("/com/root/tomaszm/MainRoot.fxml"));

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-31
    • 2016-06-28
    • 1970-01-01
    • 1970-01-01
    • 2019-01-05
    相关资源
    最近更新 更多