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

Blurry button icons with 125% monitor display scaling on Windows 10

    XMLWordPrintable

    Details

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10, Java 15 and 16, with monitor display scaling set to 125% or greater.

      A DESCRIPTION OF THE PROBLEM :
      This looks like a problem with the rendering pipeline when the monitor display scaling is 125% or greater on Windows. It's a severe regression since Java 8, there are very noticeable rendering artifacts.

      REGRESSION : Last worked in version 8

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Create JButtons with icons containing text, see attached test case.
      2. Run with Java 8 and then Java 15 or 16 using monitor with display scaling set to 125% or greater on Windows 10.

      Run the attached test case with good quality png icons containing text. I have screenshot showing the bug, and png icons, but don't see a way to attach them here.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Good quality button icon, same as with Java 8
      ACTUAL -
      Very poor quality button icon with Java 15 and 16, image is noticeably degraded with rendering artifacts

      ---------- BEGIN SOURCE ----------
      import javax.swing.ImageIcon;
      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.UIManager;

      public class TestButtonImage {

          /**
           * Create the GUI and show it. For thread safety,
           * this method should be invoked from the
           * event-dispatching thread.
           */
          private static void createAndShowGUI() {
              //Create and set up the window.
              JFrame frame = new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

              //Set up the content pane.
              JPanel panel = new JPanel();
      String url = "C:\\temp\\36point.png";
      String url72 = "C:\\temp\\72point.png";
      // Image image = Toolkit.getDefaultToolkit().createImage(url);
      // ImageIcon icon = new ImageIcon(image);
      ImageIcon icon = new ImageIcon(url);
      JButton button = new JButton(icon);

      ImageIcon icon72 = new ImageIcon(url72);
      JButton button72 = new JButton(icon72);

              panel.add(button);
              panel.add(button72);

              frame.getContentPane().add(panel);

              //Display the window.
              String javaVersion = System.getProperty("java.version");
              String osName = System.getProperty("os.name");
              frame.setTitle("Java " + javaVersion + " " + osName);
              frame.pack();
              frame.setSize(500,500);
              frame.setVisible(true);
        }

          public static void main(String[] args) {
      try {
                  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              } catch (Exception e) {
                  e.printStackTrace();
              }

              //Schedule a job for the event-dispatching thread:
              //creating and showing this application's GUI.
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      createAndShowGUI();
                  }
              });
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      -Dsun.java2d.uiScale=1

      FREQUENCY : always


        Attachments

        1. 36point.png
          36point.png
          1 kB
        2. 72point.png
          72point.png
          3 kB
        3. Capture.PNG
          Capture.PNG
          55 kB
        4. jdk9.png
          jdk9.png
          12 kB
        5. TestButtonImage.java
          2 kB

          Activity

            People

            Assignee:
            psadhukhan Prasanta Sadhukhan
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated: