protect splash screen code

This commit is contained in:
bancika
2020-04-12 11:09:00 +02:00
parent 64920a2c07
commit 1ffe70b66a
2 changed files with 19 additions and 7 deletions
@@ -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();
}
@@ -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);