From 50b9188229dc45ac4544b84ee5039ab6cef5e640 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Thu, 30 Sep 2021 17:47:12 +0200 Subject: [PATCH] Makes sure all GUI windows have the same icon --- .../userinterface/BackupGUI.java | 11 +++++++++++ .../userinterface/ServerConsoles.java | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/BackupGUI.java b/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/BackupGUI.java index 8a9b537..2f0e192 100644 --- a/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/BackupGUI.java +++ b/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/BackupGUI.java @@ -2,10 +2,14 @@ package net.knarcraft.minecraftserverlauncher.userinterface; import net.knarcraft.minecraftserverlauncher.utility.BackupUtil; +import javax.imageio.ImageIO; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.io.IOException; + +import static net.knarcraft.minecraftserverlauncher.utility.CommonFunctions.getResourceAsStream; /** * The Backup GUI is used to display backup progress @@ -33,6 +37,13 @@ public class BackupGUI implements ActionListener { frame = new JFrame("Running backup..."); frame.setBounds(100, 100, 500, 140); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); + ImageIcon img; + try { + img = new ImageIcon(ImageIO.read(getResourceAsStream("GUIIcon.png"))); + frame.setIconImage(img.getImage()); + } catch (IOException ignored) { + } + progressTextArea = new JTextArea(); progressTextArea.setEditable(false); progressBar = new JProgressBar(); diff --git a/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/ServerConsoles.java b/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/ServerConsoles.java index 7f9f0c8..df74d1b 100644 --- a/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/ServerConsoles.java +++ b/src/main/java/net/knarcraft/minecraftserverlauncher/userinterface/ServerConsoles.java @@ -1,7 +1,11 @@ package net.knarcraft.minecraftserverlauncher.userinterface; +import javax.imageio.ImageIO; import javax.swing.*; import java.awt.*; +import java.io.IOException; + +import static net.knarcraft.minecraftserverlauncher.utility.CommonFunctions.getResourceAsStream; /** * This class keeps track of all consoles @@ -31,6 +35,12 @@ public class ServerConsoles { frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); consolesTabbedPane = new JTabbedPane(JTabbedPane.TOP); frame.getContentPane().add(consolesTabbedPane, BorderLayout.CENTER); + ImageIcon img; + try { + img = new ImageIcon(ImageIO.read(getResourceAsStream("GUIIcon.png"))); + frame.setIconImage(img.getImage()); + } catch (IOException ignored) { + } } }