Bug 495064 - Java AWT TrayIcon stopped working on KDE 6.6 Plasma
Summary: Java AWT TrayIcon stopped working on KDE 6.6 Plasma
Status: RESOLVED DUPLICATE of bug 498824
Alias: None
Product: xdg-desktop-portal-kde
Classification: Plasma
Component: general (other bugs)
Version First Reported In: 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-10-23 03:54 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented 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...
Comment 3 Konrad Materka 2025-04-10 15:59:40 UTC

*** This bug has been marked as a duplicate of bug 498824 ***
Comment 4 Konrad Materka 2025-04-10 16:16:22 UTC
(In reply to Matteo Hausner from comment #2)
> I am also experiencing this issue with my app ControllerBuddy ->
> https://controllerbuddy.org

I see that ControllerBuddy has completely new code for system tray (very nice!), which works fine with KDE.
Comment 5 Matteo Hausner 2025-04-10 18:44:04 UTC
(In reply to Konrad Materka from comment #4)
> (In reply to Matteo Hausner from comment #2)
> > I am also experiencing this issue with my app ControllerBuddy ->
> > https://controllerbuddy.org
> 
> I see that ControllerBuddy has completely new code for system tray (very
> nice!), which works fine with KDE.

Yes, ControllerBuddy is now using SDL3 to handle the tray icon, so it is no longer affected by this issue.
Comment 6 Roman 2025-10-23 03:54:10 UTC
Hi. I have this problem too. The icon appears in the tray, but right-clicking it doesn't bring up a menu. In xfce, for example, everything is fine. What can I do about it?
the problem was and is on any modern version kde (