FXTrayIcon icon indicating copy to clipboard operation
FXTrayIcon copied to clipboard

Blurry Icon with FXTrayIcon, Clearer Icon with AWT

Open leewyatt opened this issue 2 years ago • 1 comments

Hi Dustin

image

I would like to report an issue regarding the tray icon display. The icon set using FXTrayIcon on the left appears to be blurry, while the system icon set using AWT on the right looks clearer. This inconsistency in the icon quality is affecting the overall user experience. It would be greatly appreciated if this issue could be addressed and the clarity of the FXTrayIcon icon improved to match the quality of the AWT system icon.

Thank you for your attention to this matter.

  • OS: windows10
  • Image: tray-icon2-windows
  • Code
        if (OSUtil.isWindows()) {
            Dimension trayIconSize = new Dimension(16, 16);
            if (FXTrayIcon.isSupported()) {
                 trayIconSize = SystemTray.getSystemTray().getTrayIconSize();
            }

            java.awt.Image image = null;
            try {
                URL url = getClass().getResource("tray-icon2-windows.png");
                assert url != null;
                image = ImageIO.read(url);
            } catch (IOException ex) {
                System.out.println(ex);
            }
            assert image != null;

            trayIcon = new FXTrayIcon(stage);
            trayIcon.setGraphic(image.getScaledInstance(trayIconSize.width, trayIconSize.height, Image.SCALE_SMOOTH));
            //trayIcon.setGraphic(new javafx.scene.image.Image(Objects.requireNonNull(JFXCentral2App.class.getResource("tray-icon2-windows.png")).toExternalForm(), trayIconSize.width, trayIconSize.height, true, true));
        }else {
            trayIcon = new FXTrayIcon(stage, Objects.requireNonNull(JFXCentral2App.class.getResource("tray-icon2.png")), 350, 210);
        }

leewyatt avatar Jul 20 '23 14:07 leewyatt

I suspect the reason is that the Windows system scales the tray icon, resulting in a clearer appearance. However, when using FXTrayIcon, the blurriness is caused by our own icon scaling.

when using FXTrayIcon and not specifying the icon size manually, if the icon size is large, only a portion of the icon will be displayed in the system tray.

leewyatt avatar Jul 20 '23 14:07 leewyatt