Browse Source

Added fatal error pop-up and exit to Gui

pull/67/head
catbref 5 years ago
parent
commit
c00481a750
  1. 26
      src/main/java/org/qora/gui/Gui.java

26
src/main/java/org/qora/gui/Gui.java

@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.JOptionPane;
import javax.swing.UIManager; import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException; import javax.swing.UnsupportedLookAndFeelException;
@ -18,7 +19,7 @@ public class Gui {
private static Gui instance; private static Gui instance;
private boolean isHeadless; private boolean isHeadless;
private SplashFrame splash = null; private SplashFrame splashFrame = null;
private SysTray sysTray = null; private SysTray sysTray = null;
private Gui() { private Gui() {
@ -37,8 +38,8 @@ public class Gui {
} }
private void showSplash() { private void showSplash() {
LOGGER.trace("Splash"); LOGGER.trace(() -> "Splash");
this.splash = SplashFrame.getInstance(); this.splashFrame = SplashFrame.getInstance();
} }
protected static BufferedImage loadImage(String resourceName) { protected static BufferedImage loadImage(String resourceName) {
@ -61,8 +62,8 @@ public class Gui {
if (this.isHeadless) if (this.isHeadless)
return; return;
this.splash.dispose(); this.splashFrame.dispose();
this.splash = null; this.splashFrame = null;
this.sysTray = SysTray.getInstance(); this.sysTray = SysTray.getInstance();
} }
@ -71,11 +72,22 @@ public class Gui {
if (this.isHeadless) if (this.isHeadless)
return; return;
if (this.splash != null) if (this.splashFrame != null)
this.splash.dispose(); this.splashFrame.dispose();
if (this.sysTray != null) if (this.sysTray != null)
this.sysTray.dispose(); this.sysTray.dispose();
} }
public void fatalError(String title, String message) {
if (this.isHeadless)
return;
shutdown();
JOptionPane.showConfirmDialog(null, message, title, JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
} }

Loading…
Cancel
Save