From 541e5794012b0d2f522edc8789e28164d0b79e4c Mon Sep 17 00:00:00 2001 From: Downforce Agent Date: Wed, 3 Jul 2024 15:35:56 -0500 Subject: [PATCH] Add window icon to new dialogs --- src/Clifford.java | 9 +++++++++ src/Waldorf.java | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/Clifford.java b/src/Clifford.java index 5a2c6e8..ad20d7d 100644 --- a/src/Clifford.java +++ b/src/Clifford.java @@ -20,6 +20,7 @@ import net.lingala.zip4j.ZipFile; import net.lingala.zip4j.exception.ZipException; import org.json.JSONObject; +import javax.imageio.ImageIO; import javax.swing.*; import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileNameExtensionFilter; @@ -28,7 +29,9 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; import java.io.File; +import java.io.IOException; import static javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE; @@ -56,6 +59,12 @@ public class Clifford implements ActionListener { creating = false; frame.add(frameContainer); + try { + BufferedImage windowIcon = ImageIO.read(new File(System.getProperty("user.dir") + "/resources/titleIcon.png")); + frame.setIconImage(windowIcon); + } catch (IOException e) { + System.out.println("ERROR: Failed to find /resources/titleIcon.png. Window will not have an icon."); + } frame.setSize(600, 300); // 1280 800 frame.setMinimumSize(new Dimension(200,100)); frame.setTitle("Options"); diff --git a/src/Waldorf.java b/src/Waldorf.java index b7dad2f..b1b06d2 100644 --- a/src/Waldorf.java +++ b/src/Waldorf.java @@ -18,12 +18,14 @@ import org.json.JSONObject; +import javax.imageio.ImageIO; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; @@ -43,6 +45,12 @@ public class Waldorf implements ActionListener { invoker = inv; frame.add(frameContainer); + try { + BufferedImage windowIcon = ImageIO.read(new File(System.getProperty("user.dir") + "/resources/titleIcon.png")); + frame.setIconImage(windowIcon); + } catch (IOException e) { + System.out.println("ERROR: Failed to find /resources/titleIcon.png. Window will not have an icon."); + } frame.setSize(600, 200); // 1280 800 frame.setMinimumSize(new Dimension(200,100)); frame.setTitle("Options");