Bug 495064 - Java AWT TrayIcon stopped working on KDE 6.6 Plasma
Summary: Java AWT TrayIcon stopped working on KDE 6.6 Plasma
Status: REPORTED
Alias: None
Product: xdg-desktop-portal-kde
Classification: Plasma
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-10-19 22:38 UTC by Davide Perini
Modified: 2025-01-25 18:37 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Davide Perini 2024-10-19 22:38:44 UTC
Running Ubuntu 24.10 and KDE 6.6 Plasma.
Java TrayIcon stopped working.

With this simple code:
```
import java.awt.*;
import java.awt.event.*;

public class TrayIconExample {
    public static void main(String[] args) {
        if (SystemTray.isSupported()) {
            SystemTray tray = SystemTray.getSystemTray();
            Image image = Toolkit.getDefaultToolkit().createImage("icon.png");
            TrayIcon trayIcon = new TrayIcon(image, "Tray Demo");

            trayIcon.setImageAutoSize(true);
            trayIcon.setToolTip("Tray Icon Demo");

            trayIcon.addMouseListener(new MouseAdapter() {
                u/Override
                public void mouseClicked(MouseEvent e) {
                    if (e.getButton() == MouseEvent.BUTTON1) {
                        System.out.println("Left button clicked");
                    } else if (e.getButton() == MouseEvent.BUTTON3) {
                        System.out.println("Right button clicked");
                    } else if (e.getButton() == MouseEvent.BUTTON2) {
                        System.out.println("Middle button clicked");
                    }
                }
            });

            try {
                tray.add(trayIcon);
            } catch (AWTException e) {
                System.err.println("TrayIcon could not be added.");
            }
        } else {
            System.err.println("System tray not supported!");
        }
    }
}
```

Tray icon is correctly added to the tray bar but there is no way to listen to mouse button on it making it unusable.

No event is triggered when I click on the tray icon.

This issue is blocking making all Java programs that uses a tray icon to not work correcly.
Comment 1 Pounder 2024-12-12 15:41:43 UTC
Doesn't seem to be distro specific, seeing this on
Arch (Plasma 6.2.4, KDE Frameworks 6.8.0, Qt 6.8.1)
Debian Trixie (Plasma 6.2.4, KDE Frameworks 6.6.0, Qt 6.7.2)
Comment 2 Matteo Hausner 2025-01-25 18:37:21 UTC
I am also experiencing this issue with my app ControllerBuddy -> https://controllerbuddy.org
As far as I can tell this appeared with KDE 6.0 - on KDE 5 the tray works flawlessly with AWT.
As this issue renders the tray icon useless, in my app I even started checking for KDE versions >= 6 to handle them as if the tray is not supported at all, which is really unfortunate... :(
I might be willing to look into this if nobody else cares, but at least some intial pointers on where to start digging would be helpful...