JDK-8282958 : Rendering Issues with Borders on Windows High-DPI systems
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 11,17
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-03-10
  • Updated: 2024-05-29
  • Resolved: 2022-11-01
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 11 JDK 17 JDK 20
11.0.19-oracleFixed 17.0.7-oracleFixed 20 b22Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
There are rendering issues, especially with borders (eg. text fields or etched borders) on high DPI monitors with Windows display scaling of 125% or 150%. They are rendered with different thicknesses or sometimes missing lines with fractional scaling.
Comments
Fix request [11u,17u] I backport this for parity with 11.0.19-oracle,17.0.7-oracle. Low risk, windows awt change. Clean backport. Tests pass and fails without the fix. SAP nighlty testing passed.
15-02-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk11u-dev/pull/1733 Date: 2023-02-14 13:30:05 +0000
14-02-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/1172 Date: 2023-02-14 13:15:54 +0000
14-02-2023

Changeset: 9911405e Author: Rajat Mahajan <rajat.m.mahajan@oracle.com> Committer: Alexey Ivanov <aivanov@openjdk.org> Date: 2022-11-01 18:38:00 +0000 URL: https://git.openjdk.org/jdk/commit/9911405e543dbe07767808bad88534abbcc03c5a
01-11-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/10681 Date: 2022-10-12 16:41:52 +0000
13-10-2022

There is also a problem rendering radio buttons and checkboxes with connected monitors with different high dpi settings. — This is tracked in JDK-8294427
06-10-2022

Collected x, y translation and width, height and thickness data for the Textfield border and also for background with varying scaling values. After this I was able to improve the calculations for these values for both the border and background. Now I see all borders scaled properly and with equal thickness for all sides of the border for all windows supported scaling values , i.e., 1.25, 1.5, 1.75, 2.25, 2.5, 2.75, 3.25, 3.5, 3.75, 4.25, 4.5, 4.75 and so on and so forth. It works for some of the arbitrary scaling values and not for all, for example I see a missing border on bottom side for 1.33.
08-08-2022

Applying transformations to background and border both is still not working as intended. Collected data for the x,y , width, height values for different scaling factors for background and border and using it to see how we can get the border and background aligned.
25-07-2022

Applying the fix for background painting along-with border painting seems to show better visual results for all scale factor values. With this the border seems to cover the whole textfield with no background visible like it was happening earlier with 1.25, 1.75, 2.25 , etc. But I still see some some issue with border edges at the start which goes away when I resize the window. Looking into this further to see how can the fix be applied for both the background and border so that it works for all scale factors.
15-07-2022

Current code changes for the fix are pretty much in line with Alisen's fix for JDK-8279614, with some modifications to fit the Lineborder code. It works good for Scale factor 1.5, 2.0, 2.5, 3.0 and the Textfield border thickness is same for all sides. It is still not working fine for Scale factor 1.25, 1.75, 2.25, 2.75 . There is some issue where the border is getting offset by half a pixel and I am looking into checking if this can be fixed.
24-06-2022

Have a working POC that fixes the issue with different border thickness for different sides of the Textfield border. Currently I am testing it with different DPIs, border thickness, round vs regular borders, etc. and fixing any issues highlighted in the testing. From what I see, overall a larger and more structural change to fix all UI elements for HiDPI will be needed to fix this bug.
13-06-2022

as not on review (yet) and not a regression in 19, then move to "20" as a possible target
08-06-2022

I have applied Alisen's changes for JDK-8279614 to my latest JDK branch and I see that it is fixing the etched border issue highlighted in the bug. This change is still under review and needs to be approved. I am working on Textfield border thickness issue now, where the borders show different thickness Stepped through in the debugger and narrowed down on the piece of code in paintBorder() in LineBorder.java for text field border. Trying with code from Alisen's change after modification and working on fixing this issue with that.
27-05-2022

[~prr] I agree, tried with fix for 8279614 under code review and it fixes Radio Button group border issue I saw with this bug and saw some issues with line width as pointed out in the review. Focusing on text fields to start with, and will also try to capture other related issues with other UI elements using sub-tasks.
18-03-2022

The dev working on 8279614 confirmed that even though his fix isn't final (and is being reworked) that it seems like it should fix the issues with borders reported here. So I suggest to focus first - in this bug - on the other issues with TextField etc - and yes, as Alexey maybe is implying, there may be other open more specific bugs too. This bug is trying to capture too many issues.
17-03-2022

Reproduced the issue with attached test case with 125%, 150% scaling with my HIDPI monitor on Windows 10. Investigating further.
11-03-2022

[~prr] Thanks! I remember I saw a discussion about a similar issue but I couldn't find it. It was JDK-8279614. There are other similar bugs: • JDK-8241561: Borders are sometimes painted too thick on HiDPI screens with Windows-LAF • JDK-8233789: A part of frame line of JComboBox lacks with HIDPI
11-03-2022

Attach the test case. Are you sure this is a 2D bug ? I seriously doubt it. It seems like a Swing issue. I'm going to change it. And a main bug should never be targeted to an old update release, that's what backports are for. Also there's work in progress on a bug that deals with borders https://bugs.openjdk.java.net/browse/JDK-8279614 so some - or all - of this may be duplicates. And maybe this needs to be split up.
11-03-2022