JDK-8323977 : TrayIcon notifications show corrupted icon after DPI changes
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8,11,17,21,22,23
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2024-01-05
  • Updated: 2024-03-25
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.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
JDK 21.0.1
Windows 11

A DESCRIPTION OF THE PROBLEM :
Notifications shown from a TrayIcon shows a corrupted image even if the image is correctly visible in the traybar.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Simply create a trayicon with an image and show a notification from it.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Image should be correctly visible in the notification
ACTUAL -
Image shown in the notification is corrupted

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

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);
        Image image= Toolkit.getDefaultToolkit().getImage(Main.class.getResource("/org/your_resource_package/your_image.png"));

        var trayIcon = new TrayIcon(image);
        SystemTray.getSystemTray().add(trayIcon);
        trayIcon.setImageAutoSize(true);

        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 ----------

CUSTOMER SUBMITTED WORKAROUND :
no workaround found

FREQUENCY : always



Comments
This happens on Windows 10 and 11 in High DPI environment. The icon displayed in the notification banner also becomes distorted after DPI of the main display is changed. I've got a reproducer test case which generates a list of icons like in test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java [1]. This bug was reported along with JDK-8310352 in a client-libs-dev discussion [2], I confirmed [3] the bug but I didn't submit the bug unfortunately. [1] https://github.com/openjdk/jdk/blob/master/test/jdk/java/awt/TrayIcon/TrayIconScalingTest.java [2] https://mail.openjdk.org/pipermail/client-libs-dev/2023-August/014556.html [3] https://mail.openjdk.org/pipermail/client-libs-dev/2023-August/014568.html
17-01-2024

Checked with attached testcase in Windows 11, issue is reproducible<attached screenshot> Test Result ============ JDK8: Fail JDK8u401: Fail JDK11.0.22: Fail JDK17.0.10: Fail JDK21.0.2: Fail JDK22ea31: Fail JDK23ea05: Fail
17-01-2024