Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blurry Icon with FXTrayIcon, Clearer Icon with AWT #81

Open
leewyatt opened this issue Jul 20, 2023 · 1 comment
Open

Blurry Icon with FXTrayIcon, Clearer Icon with AWT #81

leewyatt opened this issue Jul 20, 2023 · 1 comment

Comments

@leewyatt
Copy link

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant