Windows 11: Notifications vanishes after few seconds.

Aleksei Ivanov alexey.ivanov at oracle.com
Mon Jan 8 16:59:40 UTC 2024


Hi Davide,

The bug that you reported has been moved to JDK project in JBS, you can 
view it as JDK-8315647 [1]. You should've received a link to it.

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

What kind of answer did you expect to receive?

You already asked this question on this mailing list in August [2]. I 
replied to your question [3]. Nothing has changed since August. It is 
not a bug in Java because a native Win32 app behaves the same way.

I compiled and tested the sample [4], it behaves in Windows 11 as Java 
does: the displayed balloon notification does not go to notification 
centre. However, if I open notification centre while the balloon is 
displayed, it remains there. If I disable "Show notification banners" 
and leave "Show notifications in notification centre" enabled, the 
balloon goes directly to notification centre without displaying a banner.

You can compile and test the sample too:

git clone --filter=blob:none --sparse 
https://github.com/microsoft/Windows-classic-samples.git windows-samples
cd windows-samples
git sparse-checkout add 
Samples/Win7Samples/winui/shell/appshellintegration/NotificationIcon

Navigate to the NotificationIcon folder and open NotificationIcon.sln in 
Visual Studio to compile and run it.

If required, I can attach the compiled version of the application.


I have closed JDK-8315647 as duplicate of JDK-8310352 [5].

-- 
Regards,
Alexey


[1] https://bugs.openjdk.org/browse/JDK-8315647
[2] 
https://mail.openjdk.org/pipermail/client-libs-dev/2023-August/014556.html
[3] 
https://mail.openjdk.org/pipermail/client-libs-dev/2023-August/014557.html
[4] 
https://learn.microsoft.com/en-us/windows/win32/shell/samples-notificationicon
[5] https://bugs.openjdk.org/browse/JDK-8310352

On 2024-01-05 12:41, Davide Perini wrote:
> 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