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

setMaximizedBounds ignored display scaling (large Fonts) on Windows

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "9"
      Java(TM) SE Runtime Environment (build 9+181)
      Java HotSpot(TM) Server VM (build 9+181, mixed mode, emulated-client, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.15063]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      The display has a scaling of 125% or larger. The value of "Change the size of text, apps, and other items:" in the display settings.

      A DESCRIPTION OF THE PROBLEM :
      The method JFrame.setMaximizedBounds ignored the scaling of the display or the calculating is wrong. The result is that the maximize window is to small. If the display scaling is 125% then the size is 25% to small.

      REGRESSION. Last worked in version 8u152

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      * Change the scaling of the display to a value that is larger as 100% in the windows display settings
      * run the test with Java 9 and Java 8

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Both Java versions should show the same windows size but it is different.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.Frame;
      import java.awt.GraphicsConfiguration;
      import java.awt.Insets;
      import java.awt.Rectangle;

      import javax.swing.JFrame;
      import javax.swing.JLabel;

      public class TestMaximizedBounds {

          public static void main( String[] args ) {
              JFrame.setDefaultLookAndFeelDecorated( true );
              JFrame frame = new JFrame( "TestMaximizedBounds" );
              frame.getContentPane().add( new JLabel("TestMaximizedBounds") );
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

              // set a maximum bounds without the task bar
              GraphicsConfiguration graphicsConfiguration = frame.getGraphicsConfiguration();
              Rectangle screenbounds = graphicsConfiguration.getBounds();
              Insets screenInsets = frame.getToolkit().getScreenInsets( graphicsConfiguration );
              frame.setMaximizedBounds( new Rectangle( screenInsets.left, screenInsets.top, screenbounds.width - screenInsets.left - screenInsets.right, screenbounds.height - screenInsets.top - screenInsets.bottom ) );
              frame.setExtendedState( Frame.MAXIMIZED_BOTH );

              frame.pack();
              frame.setVisible( true );
          }
      }

      ---------- END SOURCE ----------

        1. 9.PNG
          9.PNG
          10 kB
        2. 8u144.png
          8u144.png
          18 kB
        3. TestMaximizedBounds.java
          1 kB
        4. 8u144.png
          8u144.png
          18 kB
        5. 9.PNG
          9.PNG
          10 kB
        6. TestMaximizedBounds.java
          1 kB
        7. 8u144.png
          8u144.png
          18 kB
        8. 9.PNG
          9.PNG
          10 kB
        9. TestMaximizedBounds.java
          1 kB

            pardesha Pardeep Sharma
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: