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

Swing UI breaks with disabled sun.java2d.uiScale on Windows

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10, starting by JDK 16

      A DESCRIPTION OF THE PROBLEM :
      Precondition is a Swing application that deactivates the sun.java2d.uiScale property.
      When a Swing Window (JFrame or JDialog) is dragged from one monitor with 100% DPI scaling to an other monitor with e.g. 125% DPI scaling, the Window has unpainted regions (and UI components are not usable anymore).

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Use Windows 10
      2. Set up two monitors, one with 100% and another with 125% DPI scaling
      3. Start the code that creates a Swing JDIialog
      4. Drag it from the 100% DPI monitor to the 125% DPI monitor

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      JDialog should stay with the same size (so it is under JDK 15) and should not have unpainted regions.
      ACTUAL -
      JDialog increases in size and the increased region is unpainted.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JDialog;

      public class Main {
        public static void main(String[] args) {
          System.setProperty("sun.java2d.uiScale.enabled", "false");

          JDialog dialog = new JDialog();
          dialog.setTitle("DIALOG");
          dialog.setSize(200, 200);

          dialog.setVisible(true);
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      JDK 15 or lower
      or System.setProperty("sun.java2d.uiScale.enabled", "true");

      FREQUENCY : always


            rmahajan Rajat Mahajan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: