JDK-8323247 : Notifications vanishes from Windows 11 notification center
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 21
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2024-01-05
  • Updated: 2024-01-09
  • Resolved: 2024-01-09
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows 11
JDK 21.0.1

A DESCRIPTION OF THE PROBLEM :
Notifications vanishes from Windows 11 notification center after few seconds no matter what Windows settings is in use.


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Notifications should stick into notification center if not cancelled, they vanishes after few seconds instead.

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

public class Main {
    public static void main(String[] args) throws Exception {
        var frame = new Frame("Notification Example");
        var button = new Button("Notify");
        frame.add(button);
        var image = new BufferedImage(32, 32, BufferedImage.TYPE_4BYTE_ABGR);
        var trayIcon = new TrayIcon(image);
        SystemTray.getSystemTray().add(trayIcon);

        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                e.getWindow().dispose();
                System.exit(0);
            }
        });
        button.addActionListener(e -> {
            trayIcon.displayMessage("Hello World", "Lorem ipsum", TrayIcon.MessageType.INFO);
        });

        frame.pack();
        frame.setVisible(true);
    }
}
---------- END SOURCE ----------

FREQUENCY : always



Comments
Duplicate of JDK-8310352
09-01-2024