JDK-8187367 : Numerous swing display problems with scaled displays on Windows
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 9
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2017-09-07
  • Updated: 2017-12-26
  • Resolved: 2017-11-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 10
10 b34Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]


EXTRA RELEVANT SYSTEM CONFIGURATION :
Display scaling at 170%

A DESCRIPTION OF THE PROBLEM :
Swing applications now look bad with a scaled display on Windows.

The comments to 8187151 claim that this is not due to a problem with dpi awareness.

See http://www.jgrasp.org/tmp/scale.png which shows a file chooser under Java 9 and Java 8 with 170% display scaling.

The file chooser under Java 9 has odd white lines near the right sides of the buttons and scrollbar, differing appearance of identical icons (even if the images don't scale well, the icons should all look the same), badly scaled icon images (more image sizes need to be provided if that is what is happening, or they need to be drawn on-the-fly). The borders of the combo boxes do not look right. The triangle icon on one of the combo boxes and on the scroll bar are asymmetrical.

All swing applications will look bad at this scaling level.

REGRESSION.  Last worked in version 8u152

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the code on a system with 170% display scaling.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Normal-looking file chooser dialog (though possibly larger than under Java 8).
ACTUAL -
Badly rendered file chooser dialog.

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.io.File;

public class DpiAwareBug {
   public static void main(String args[]) {
      SwingUtilities.invokeLater(
         new Runnable() {
            public void run() {
               JFileChooser fc = new JFileChooser();
               fc.showOpenDialog(null);
            }
         });
   }
}

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


Comments
To maintainers: if some other issues will be found in these code paths, then it will make sense to drop usage of VolatileImages here, and always use BI as a backbuffers.(it should be checked that BI will be cached in the video memory)
13-11-2017

http://mail.openjdk.java.net/pipermail/swing-dev/2017-September/007745.html
24-10-2017

There are several issues herae. 1. Artifacts on flat painted surfaces at fractional scale. Regression of JDK-8163193 and JDK-8073320. 2. All edge artifacts caused by JDK-8073320 because Math.ceil() is used as rounding method for coordinates. To address this issue the JDK-8187585 was created. 3. Look and Feels has UI elements which looks bad after up scaling. This is a major issue of most Swing Look and Feels: some UI elements which are drawn per pixel or loaded from fixed size images do not look good after being up-scaled to HiDPI screen resolution. JDK-8187586 addresses this issue.
15-09-2017

Mostly border problems take place at fractional scales like 1.25, 1.5, 1.75. White lines appear on scales like 1.3, 1.7.
14-09-2017

Windows 10 (64-bit) Display scaled to 175% JDK (8, 8u144, 8u152 ea b05, and 9 ea b181) Attached screenshots display the comparison of a file chooser under Java 9 and Java 8 with 175% display scaling. From the description: "The file chooser under Java 9 has odd white lines near the right sides of the buttons and scrollbar, differing appearance of identical icons (even if the images don't scale well, the icons should all look the same), badly scaled icon images (more image sizes need to be provided if that is what is happening, or they need to be drawn on-the-fly). The borders of the combo boxes do not look right. The triangle icon on one of the combo boxes and on the scroll bar are asymmetrical." Results: 8: OK 8u144: OK 8u152 ea b05: OK 9 ea b181: FAIL To verify, run the attached test case with respective JDK version (see attached screenshots as reference). This is likely a duplicate of JDK-8187151, but may require additional clarification.
08-09-2017