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 () {
@@ -26,13 +28,18 @@ public static void create() {
2628 return ;
2729 }
2830
29- Image fafLogo = null ;
30- try {
31- fafLogo = ImageIO . read ( new URL ( FAF_LOGO_URL ));
32- } catch ( IOException e ) {
33- log .error ("Couldn't load FAF tray icon logo from URL" );
34- return ;
31+ Image fafLogo = null ;
32+ try ( final InputStream imageStream = TrayIcon . class . getClassLoader ()
33+ . getResourceAsStream ( FAF_LOGO_FILE )) {
34+ if ( imageStream == null ) {
35+ log .error ("Couldn't find '{}' in resource folder" , FAF_LOGO_FILE );
36+ return ;
3537 }
38+ fafLogo = ImageIO .read (imageStream );
39+ } catch (IOException e ) {
40+ log .error ("Couldn't load FAF tray icon logo from resource folder" , e );
41+ return ;
42+ }
3643
3744 fafLogo = fafLogo .getScaledInstance (
3845 new java .awt .TrayIcon (fafLogo ).getSize ().width ,
0 commit comments