JDK-8187616 : setMaximizedBounds ignored display scaling (large Fonts) on Windows
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 9
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_10
  • CPU: x86
  • Submitted: 2017-09-15
  • Updated: 2019-08-02
  • Resolved: 2017-09-18
Related Reports
Duplicate :  
Description
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 ----------


Comments
Environment: Windows 10 (64-bit) Display scaled to 175% (125%+) JDK 8u144, 8u152 ea b05 and 9 ea b181 Results: See attached screenshots depicting results with JDK 8u and 9 ea. When run with 8u, the scaling of display is ot considered, however with 9, it seems behaving fine. JDK 9 delivers hidpi for windows as per JEP http://openjdk.java.net/jeps/263 therefore this does not affected. This seems a duplicate of JDK-8180815.
18-09-2017