Windows 8 appears to make tray icons be 20 x 20 pixels. It seems as though Java still thinks they should be 16 x 16 pixels. This is causing some bad distortion as Java scales things down, and then Windows scales things back up. The following example uses these three images to create three tray icons that look like this (note the distortion):
.
import java.awt.Image;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
public class TrayTest
{
public static void main(String[] args) throws Exception
{
final SystemTray tray = SystemTray.getSystemTray();
TrayIcon trayIcon16 = new TrayIcon(getImage("16pxBlue.png"));
tray.add(trayIcon16);
TrayIcon trayIcon20 = new TrayIcon(getImage("20pxRed.png"));
tray.add(trayIcon20);
TrayIcon trayIcon20autoSize = new TrayIcon(getImage("20pxGreen.png"));
trayIcon20autoSize.setImageAutoSize(true);
tray.add(trayIcon20autoSize);
}
public static Image getImage(String resource)
{
return Toolkit.getDefaultToolkit().createImage(TrayTest.class.getResource(resource));
}
}
This is what the whole thing looks like magnified with pixel lines added (opening image in a new tab will give you a clearer view):
My question: How can I prevent Java / Windows 8 from distorting my icons?