as title.
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() {
@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.
Is this a known issue?