Java.awt.SystemTray does not display tray icon properly

awt, icons, java, swing, system-tray

Solution

Possibilities include `TrayIcon.setImageAutoSize()` and maybe your OS (assuming Windows) is set to some kind of high-dpi display like 120 or 144 and Java doesn't adapt to that correctly.

Problem

A snippet of my code is below: ``` SystemTray systray = SystemTray.getSystemTray(); try{ TrayIcon trayicon = new TrayIcon(new ImageIO.read(new File("icon.png")),"I am a description"); } catch(IOException e) { e.printStackTrace(); } ``` Everything runs smoothly but the image displayed in the system tray is cut off. Only the top left portion is displayed unless I shrink down to 16x16 (from 40x40). The `icon.png` is an image file that is loaded properly (not null). I thought that system tray icon files could be 40px? Could someone please explain to me what's the issue here?

Original source