44import com .faforever .iceadapter .debug .Debug ;
55import com .faforever .iceadapter .debug .DebugWindow ;
66import com .faforever .iceadapter .debug .InfoWindow ;
7- import java .awt .*;
7+ import java .awt .AWTException ;
8+ import java .awt .Image ;
9+ import java .awt .SystemTray ;
810import java .awt .event .MouseEvent ;
911import java .awt .event .MouseListener ;
1012import java .io .IOException ;
11- import java .net . URL ;
13+ import java .io . InputStream ;
1214import java .util .concurrent .CompletableFuture ;
1315import javax .imageio .ImageIO ;
14- import javax .swing .* ;
16+ import javax .swing .SwingUtilities ;
1517import lombok .extern .slf4j .Slf4j ;
1618
1719@ Slf4j
1820public class TrayIcon {
1921
20- public static final String FAF_LOGO_URL = "https://faforever.com/images/ faf-logo.png" ;
22+ public static final String FAF_LOGO_FILE = "faf-logo.png" ;
2123 private static volatile java .awt .TrayIcon trayIcon ;
2224
2325 public static void create () {
@@ -27,10 +29,14 @@ public static void create() {
2729 }
2830
2931 Image fafLogo = null ;
30- try {
31- fafLogo = ImageIO .read (new URL (FAF_LOGO_URL ));
32+ try (final InputStream imageStream = TrayIcon .class .getClassLoader ().getResourceAsStream (FAF_LOGO_FILE )) {
33+ if (imageStream == null ) {
34+ log .error ("Couldn't find '{}' in resource folder" , FAF_LOGO_FILE );
35+ return ;
36+ }
37+ fafLogo = ImageIO .read (imageStream );
3238 } catch (IOException e ) {
33- log .error ("Couldn't load FAF tray icon logo from URL" );
39+ log .error ("Couldn't load FAF tray icon logo from resource folder" , e );
3440 return ;
3541 }
3642
0 commit comments