dyorgio / macos-tray-icon-fixer

Fix appearance of Java TrayIcon on Mojave, Catalina and BigSur
MIT License
5 stars 2 forks source link

macOs TrayIcon Fixer

Fix appearance of Java TrayIcon on macOs Mojave, Catalina and BigSur.

Why use it?

Usage

// Verify theme to choose image version
Image iconImage = MacOSTrayIconFixer.getInitialIcon(blackImage, whiteImage);
// Create your TrayIcon using image
TrayIcon icon = new TrayIcon(iconImage, "Test");
// (Optional) add action and menu
icon.addActionListener((e) -> System.out.println("examples.BasicUsage.main():" + SwingUtilities.isEventDispatchThread()));

// Include in SystemTray BEFORE call fixer
SystemTray.getSystemTray().add(icon);

// Fix
MacOSTrayIconFixer.fix(icon, blackImage, whiteImage, false, 0);