Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8323977

TrayIcon notifications show corrupted icon after DPI changes

XMLWordPrintable

    • generic
    • generic

      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


        1. jdk22ea_notificatoin.png
          jdk22ea_notificatoin.png
          90 kB
        2. jdk22ea_trayicon.png
          jdk22ea_trayicon.png
          78 kB
        3. JDK8_notification.png
          JDK8_notification.png
          82 kB
        4. JDK8_trayicon.png
          JDK8_trayicon.png
          88 kB

            kizune Alexander Zuev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: