Java.awt.SystemTray does not display tray icon

Below is a snippet of my code:

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 works smoothly, but the image displayed on the taskbar turns off. Only the upper left part is displayed, if I do not decrease to 16x16 (from 40x40). icon.png is an image file that is loaded correctly (but not null). I thought the system tray icon files could be 40 pixels?

Can someone please explain to me what the problem is?

+6
source share
1 answer

Features include TrayIcon.setImageAutoSize() , and maybe your OS (assuming Windows) is configured for some kind of high-resolution display per inch, such as 120 or 144, and Java is not suitable for this.

+11
source

Source: https://habr.com/ru/post/917029/


All Articles