From 2ed6b8bedbaad6c9b6739cdf1ea487649cef9c78 Mon Sep 17 00:00:00 2001 From: Kristian Knarvik Date: Mon, 17 Aug 2020 13:59:19 +0200 Subject: [PATCH] Fixes the tray image not being loaded --- .../userinterface/ServerLauncherGUI.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/ServerLauncherGUI.java b/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/ServerLauncherGUI.java index 31e73ed..77eb499 100644 --- a/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/ServerLauncherGUI.java +++ b/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/ServerLauncherGUI.java @@ -16,11 +16,7 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; +import java.io.*; import java.util.ArrayList; import java.util.Objects; import java.util.Scanner; @@ -444,7 +440,14 @@ public class ServerLauncherGUI extends MessageHandler implements ActionListener, private void tray() { if (SystemTray.isSupported()) { tray = SystemTray.getSystemTray(); - Image trayImage = Toolkit.getDefaultToolkit().getImage("files/GUIIcon.png"); + InputStream imageStream = CommonFunctions.getResourceAsStream("GUIIcon.png"); + Image trayImage; + try { + trayImage = ImageIO.read(imageStream); + } catch (IOException e) { + trayImage = Toolkit.getDefaultToolkit().getImage("resources/GUIIcon.png"); + e.printStackTrace(); + } PopupMenu popup = new PopupMenu(); trayIcon = new TrayIcon(trayImage, "Minecraft Server Launcher", popup); trayIcon.setImageAutoSize(true);