我正在尝试构建具有多个视图的应用程序。我已经成功添加了两个视图,但是当我尝试切换到第三个视图时出现错误:
Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: Location is not set.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409)
at com.airhacks.afterburner.views.FXMLView.loadSynchronously(FXMLView.java:91)
at com.airhacks.afterburner.views.FXMLView.initializeFXMLLoader(FXMLView.java:100)
at com.airhacks.afterburner.views.FXMLView.getPresenter(FXMLView.java:179)
at com.testapp.gpa.TestApp.lambda$init$2(TestApp.java:46)
at com.testapp.gpa.TestApp.access$lambda$2(TestApp.java)
at com.testapp.gpa.TestApp$$Lambda$5.get(Unknown Source)
at com.gluonhq.impl.charm.a.d.a.a(SourceFile:32)
at com.gluonhq.charm.glisten.application.MobileApplication.switchView(SourceFile:344)
at com.gluonhq.charm.glisten.application.MobileApplication.switchView(SourceFile:312)
项目结构
我可以从 homeview 切换到 SemesterView。但我无法切换到 CourseView。视图只是扩展 FXMLView 类的空类。我正在关注 Comments 示例应用程序的项目结构。这是 course.fxml 文件的第一行
<View maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="400.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.testapp.views.courses.CoursePresenter">
它指向控制器类。