Windows 11: Notifications vanishes after few seconds.

Davide Perini perini.davide at dpsoftware.org
Fri Jan 5 12:41:05 UTC 2024


With previous version of Windows and JDK notification sticked in the 
Windows Notification Center forever until cancelled.

Since the latest Windows/JDK, notifications vanishes automatically after 
few seconds.

### Code to reproduce the problem

```
import java.awt.*;

public class Main {
     public static void main(String[] args) throws Exception {
         SystemTray tray = SystemTray.getSystemTray();

         Image image = Toolkit.getDefaultToolkit().createImage("");
         TrayIcon trayIcon = new TrayIcon(image);
         trayIcon.setImageAutoSize(true);
         trayIcon.setToolTip("Demo");
         tray.add(trayIcon);

         trayIcon.displayMessage("Hello, World", "notification demo", 
TrayIcon.MessageType.INFO);
     }
}
```

### Expected Results

Notifications sent from a TrayIcon should not vanish automatically after 
few seconds but should stay in the notification center until cancelled 
by the user.

### Actual Results

Notifications sent from a TrayIcon vanishes automatically after few seconds

### What Java Version are you using?

21.0.1

### What is your operating system and platform?

Windows 11

Is there a way to workaround this JDK bug?
I opened a bug report months ago but no one answered.

Thanks
Davide


More information about the client-libs-dev mailing list