Fixes the tray image not being loaded

This commit is contained in:
Kristian Knarvik 2020-08-17 13:59:19 +02:00
parent ba9b192790
commit 2ed6b8bedb

View File

@ -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);