Add error catch on FXMLLoader

This commit is contained in:
Oystein Kristoffer Tveit 2021-02-17 21:17:02 +01:00
parent 8dfcaa36ec
commit c8d37c2754
1 changed files with 9 additions and 1 deletions

View File

@ -24,7 +24,15 @@ public class Main extends Application {
public void start(Stage window) throws IOException {
window.setTitle("Hello world");
Parent document = FXMLLoader.load(getClass().getResource("/fxml/Main.fxml"));
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/fxml/Main.fxml"));
Parent document;
try {
document = fxmlLoader.load();
} catch (IOException e) {
throw new RuntimeException(e);
}
Scene scene = new Scene(document);
window.setScene(scene);
window.show();