【发布时间】:2016-07-18 12:28:11
【问题描述】:
下面是代码:
@Override
public void start(Stage primaryStage) {
System.out.println("Enter start method");
this.primaryStage = primaryStage;
this.primaryStage.setTitle("Bank Account App");
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(MainApp.class.getResource("view/Overview.fxml"));
System.out.println("Location is set");
AnchorPane homePage = (AnchorPane) loader.load();
OverviewController controller = loader.getController();
controller.setMainApp(this);
// Show the scene containing the root layout.
Scene scene = new Scene(homePage);
primaryStage.setScene(scene);
primaryStage.show();
System.out.println("Showed successfully");
this.primaryStage.setWidth(800);
} catch (IOException e) {
System.out.println("Not Working");;
}
}
这是错误信息:
Caused by: java.lang.IllegalStateException: Location is not set.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2434)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2409``)
at Question2.Controller.MainApp.start(MainApp.java:40)
为什么AnchorPane homePage = (AnchorPane) loader.load(); 行不起作用?
我确信我的 fxml 文件将锚窗格作为其父级。
【问题讨论】:
-
有many other questions引用了这个错误信息。你看过他们中的任何一个吗?
标签: javafx fxmlloader