Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java.awt.SystemTray does not display tray icon properly

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?

like image 327
user1418454 Avatar asked May 30 '12 16:05

user1418454


1 Answers

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.

like image 169
Jim Avatar answered Nov 15 '22 15:11

Jim