diff --git a/src/main/java/de/felixroske/jfxsupport/AbstractJavaFxApplicationSupport.java b/src/main/java/de/felixroske/jfxsupport/AbstractJavaFxApplicationSupport.java index a8ddd69..9ce66d0 100644 --- a/src/main/java/de/felixroske/jfxsupport/AbstractJavaFxApplicationSupport.java +++ b/src/main/java/de/felixroske/jfxsupport/AbstractJavaFxApplicationSupport.java @@ -89,38 +89,52 @@ public static void showView(final Class window, fina newStage.showAndWait(); } - /* - * (non-Javadoc) - * - * @see javafx.application.Application#init() - */ - @Override - public void init() throws Exception { - CompletableFuture.supplyAsync(() -> { - final ConfigurableApplicationContext ctx = SpringApplication.run(this.getClass(), savedArgs); - - final List fsImages = PropertyReaderHelper.get(ctx.getEnvironment(), "javafx.appicons"); - - if (!fsImages.isEmpty()) { - fsImages.forEach((s) -> icons.add(new Image(getClass().getResource(s).toExternalForm()))); - } else { // add factory images - icons.add(new Image(getClass().getResource("/icons/gear_16x16.png").toExternalForm())); - icons.add(new Image(getClass().getResource("/icons/gear_24x24.png").toExternalForm())); - icons.add(new Image(getClass().getResource("/icons/gear_36x36.png").toExternalForm())); - icons.add(new Image(getClass().getResource("/icons/gear_42x42.png").toExternalForm())); - icons.add(new Image(getClass().getResource("/icons/gear_64x64.png").toExternalForm())); - } - return ctx; - }).whenComplete((ctx, throwable) -> { - if(throwable != null) { - LOGGER.error("Failed to load spring application context: ", throwable); - Platform.runLater(() -> showErrorAlert(throwable)); - } - else { - launchApplicationView(ctx); - } - }); - } + private void loadIcons(ConfigurableApplicationContext ctx) + { + try { + final List fsImages = PropertyReaderHelper.get(ctx.getEnvironment(), "javafx.appicons"); + + if (!fsImages.isEmpty()) { + fsImages.forEach((s) -> + { + Image img = new Image(getClass().getResource(s).toExternalForm()); + icons.add(img); + } + ); + } else { // add factory images + icons.add(new Image(getClass().getResource("/icons/gear_16x16.png").toExternalForm())); + icons.add(new Image(getClass().getResource("/icons/gear_24x24.png").toExternalForm())); + icons.add(new Image(getClass().getResource("/icons/gear_36x36.png").toExternalForm())); + icons.add(new Image(getClass().getResource("/icons/gear_42x42.png").toExternalForm())); + icons.add(new Image(getClass().getResource("/icons/gear_64x64.png").toExternalForm())); + } + } catch (Exception e) { + LOGGER.error("Failed to load icons: ", e); + } + + + } + /* + * (non-Javadoc) + * + * @see javafx.application.Application#init() + */ + @Override + public void init() throws Exception + { + CompletableFuture.supplyAsync(() -> { + return SpringApplication.run(this.getClass(), savedArgs); + }).whenComplete((ctx, throwable) -> { + if (throwable != null) { + LOGGER.error("Failed to load spring application context: ", throwable); + Platform.runLater(() -> showErrorAlert(throwable)); + } else { + Platform.runLater(() -> { + loadIcons(ctx); + launchApplicationView(ctx);}); + } + }); + } /* * (non-Javadoc)