JDK-8342009 : Tray Icon does not work on the latest Ubuntu 24.10 and KDE 6.6 in general
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 23
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2024-10-12
  • Updated: 2024-10-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 24
24Unresolved
Description
ADDITIONAL SYSTEM INFORMATION :
Ubuntu 24.10 and KDE 6.6 in general

A DESCRIPTION OF THE PROBLEM :
Tray Icon stopped working on Ubuntu 24.10 and on every distros that bundles KDE 6.6 more in general.
TrayIcon is added to the traybar but the mouse listener does not work so no way to listen for a click on it making it unusable.




STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just try to create a tray icon and listen for a mouse button on it. Code samples below.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Mouse event on the tray icon should trigger the listener but nothing happen.
ACTUAL -
If I click the tray icon, nothing happen.

---------- BEGIN SOURCE ----------
import java.awt.*;
import java.awt.event.*;

public class TrayIconExample {

    public static void main(String[] args) {
        // Create a new tray icon
        SystemTray tray = SystemTray.getSystemTray();
        Image image = Toolkit.getDefaultToolkit().getImage("path/to/your/icon.png"); // Replace with the path to your image
        PopupMenu popup = new PopupMenu();
        MenuItem exitItem = new MenuItem("Exit");
        popup.add(exitItem);

        TrayIcon trayIcon = new TrayIcon(image, "My Tray Icon", popup);
        try {
            tray.add(trayIcon);
        } catch (AWTException e) {
            System.out.println("Error: tray icon not supported");
            System.exit(1);
        }

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

                }
            }
        });

        // Add a listener for the exit event
        exitItem.addActionListener(e -> System.exit(0));

        // Main loop to keep the application running
        while (true) {
            try {
                Thread.sleep(1000); // Check every second
            } catch (InterruptedException ex) {
                // Handle the interruption
            }
        }
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
no workaround found. blocking issue.

FREQUENCY : always



Comments
The observations on Windows 11: JDK 23: Passed, the mouse event listener was triggered. Need Ubuntu 24.10 and KDE 6.6 to further verify the issue.
13-10-2024