From 1ffe70b66a25497430f26f066c4211ae572cc3fe Mon Sep 17 00:00:00 2001 From: bancika Date: Sun, 12 Apr 2020 11:09:00 +0200 Subject: [PATCH] protect splash screen code --- .../diylc-swing/src/org/diylc/DIYLCSplash.java | 8 ++++---- .../src/org/diylc/DIYLCStarter.java | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/diylc/diylc-swing/src/org/diylc/DIYLCSplash.java b/diylc/diylc-swing/src/org/diylc/DIYLCSplash.java index 71191aa1..ad27824d 100644 --- a/diylc/diylc-swing/src/org/diylc/DIYLCSplash.java +++ b/diylc/diylc-swing/src/org/diylc/DIYLCSplash.java @@ -95,7 +95,7 @@ public class DIYLCSplash extends JDialog { private ImageIcon film = null; - public ImageIcon getFilm() { + private ImageIcon getFilm() { if (film == null) { film = (ImageIcon) IconLoader.SplashFilm.getIcon(); } @@ -104,7 +104,7 @@ public class DIYLCSplash extends JDialog { private ImageIcon ceramic = null; - public ImageIcon getCeramic() { + private ImageIcon getCeramic() { if (ceramic == null) { ceramic = (ImageIcon) IconLoader.SplashCeramic.getIcon(); } @@ -113,7 +113,7 @@ public class DIYLCSplash extends JDialog { private ImageIcon electrolytic = null; - public ImageIcon getElectrolytic() { + private ImageIcon getElectrolytic() { if (electrolytic == null) { electrolytic = (ImageIcon) IconLoader.SplashElectrolytic.getIcon(); } @@ -122,7 +122,7 @@ public class DIYLCSplash extends JDialog { private ImageIcon splash = null; - public ImageIcon getSplash() { + private ImageIcon getSplash() { if (splash == null) { splash = (ImageIcon) IconLoader.Splash.getIcon(); } diff --git a/diylc/diylc-swing/src/org/diylc/DIYLCStarter.java b/diylc/diylc-swing/src/org/diylc/DIYLCStarter.java index f0e89f24..5e4f23f2 100644 --- a/diylc/diylc-swing/src/org/diylc/DIYLCStarter.java +++ b/diylc/diylc-swing/src/org/diylc/DIYLCStarter.java @@ -59,7 +59,15 @@ public class DIYLCStarter { */ public static void main(String[] args) { // Initialize splash screen - DIYLCSplash splash = new DIYLCSplash(); + DIYLCSplash splash = null; + Exception splashException = null; + + try { + splash = new DIYLCSplash(); + } catch (Exception e) { + System.out.println("Splash screen could not be initialized: " + e.getMessage()); + splashException = e; + } URL url = DIYLCStarter.class.getResource("log4j.properties"); Properties properties = new Properties(); @@ -131,8 +139,12 @@ public class DIYLCStarter { MainFrame mainFrame = new MainFrame(); // mainFrame.setLocationRelativeTo(null); - splash.setVisible(false); - splash.dispose(); + if (splash == null) { + LOG.warn("Splash screen could not be initialized", splashException); + } else { + splash.setVisible(false); + splash.dispose(); + } mainFrame.setVisible(true);