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

Frames not correctly positioned for multiple displays at different scaling

    XMLWordPrintable

Details

    • 9
    • x86_64
    • windows_10

    Description

      ADDITIONAL SYSTEM INFORMATION :
      System with 2 displays (Display 1: 1920x1080 at 100% scaling, Display 2: 2560x1440 at 200% scaling)
      Windows 10 Build 14393
      OpenJDK 11.0.7+10.2 (LTS)

      A DESCRIPTION OF THE PROBLEM :
      Frames are not correctly positioned when the client machine running the VM has multiple displays at differing resolutions and scaling. This issue exists in these tested versions:
      v11.0.7+10.2
      v15-ea+29
      v16-ea+3

      This is regardless of which of the two displays is the main display and the orientation of the two displays to each other. If one display is at 100% scaling and the other display is at >100% scaling this problem occurs.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the sample code provided in the java.awt.GraphicsDevice class comment:

      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      GraphicsDevice[] gs = ge.getScreenDevices();
      for (int j = 0; j < gs.length; j++) {
          GraphicsDevice gd = gs[j];
          GraphicsConfiguration[] gc =gd.getConfigurations();
          for (int i=0; i < gc.length; i++) {
             JFrame f = new JFrame(gs[j].getDefaultConfiguration());
             Canvas c = new Canvas(gc[i]);
             Rectangle gcBounds = gc[i].getBounds();
             int xoffs = gcBounds.x;
             int yoffs = gcBounds.y;
             f.getContentPane().add(c);
             f.setLocation((i*50)+xoffs, (i*60)+yoffs);
             f.show();
          }
       }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected a frame to be created in the upper left corner of each display on the system.
      ACTUAL -
      Two frames appear on Screen Device #0 (one of these should have been the one positioned for Screen Device #1).

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import java.awt.*;

      class Scratch {
          public static void main(String[] args) {
              GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
              GraphicsDevice[] gs = ge.getScreenDevices();
              for (int j = 0; j < gs.length; j++) {
                  GraphicsDevice gd = gs[j];
                  GraphicsConfiguration[] gc = gd.getConfigurations();
                  for (int i = 0; i < gc.length; i++) {
                      JFrame f = new JFrame(String.format("Graphics Device #%d",j), gs[j].getDefaultConfiguration());
                      Canvas c = new Canvas(gc[i]);
                      Rectangle gcBounds = gc[i].getBounds();
                      int xoffs = gcBounds.x;
                      int yoffs = gcBounds.y;
                      f.getContentPane().add(c);
                      f.setLocation((i * 50) + xoffs, (i * 60) + yoffs);
                      f.show();
                  }
              }
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


      Attachments

        Issue Links

          Activity

            People

              serb Sergey Bylokhov
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: