JDK-8241561 : Borders are sometimes painted too thick on HiDPI screens with Windows-LAF
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 9,10,11,14,15
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2020-03-23
  • Updated: 2024-06-03
  • Resolved: 2024-05-29
Related Reports
Duplicate :  
Description
ADDITIONAL SYSTEM INFORMATION :
Windows 10, JDK 11.0.6
WQHD, 125% scaling

A DESCRIPTION OF THE PROBLEM :
Borders of Swing components are sometimed painted too thick with Windows-LAF on HiDPI screens with scaling > 100%. Recently there has been activity in Apache Netbeans to workaound this issue (see https://github.com/apache/netbeans/pull/1777).

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Start attached sample application
- Start resizing window
- In most windows sizes some borders of textfields are too thick

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Borders have always the same size
ACTUAL -
Some borders are painted to thick
See screenshots from the sample application: https://imgur.com/YRUdNIz and https://imgur.com/R03Y90h

---------- BEGIN SOURCE ----------
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import java.awt.FlowLayout;

public class HiDPITest {

    private void start() throws ClassNotFoundException, UnsupportedLookAndFeelException, InstantiationException, IllegalAccessException {

        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

        JFrame frame = new JFrame();

        JTextField tf1 = new JTextField();
        tf1.setColumns(20);
        JTextField tf2 = new JTextField();
        tf2.setColumns(20);
        JTextField tf3 = new JTextField();
        tf3.setColumns(20);
        JTextField tf4 = new JTextField();
        tf4.setColumns(20);

        JPanel p = new JPanel(new FlowLayout());
        p.add(tf1);
        p.add(tf2);
        p.add(tf3);
        p.add(tf4);

        frame.setContentPane(p);
        frame.setSize(200, 200);
        frame.setLocationRelativeTo(null);
        frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        frame.setVisible(true);

    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            try {
                new HiDPITest().start();
            } catch (ClassNotFoundException | UnsupportedLookAndFeelException | InstantiationException | IllegalAccessException e) {
                e.printStackTrace();
            }
        });
    }
}

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

FREQUENCY : always



Comments
[~tr] Yes, rendering of text field borders (in Windows Look and Feel) is resolved by JDK-8282958 in JDK 20. This bug should be closed as duplicate of JDK-8282958.
29-05-2024

Issue seems to be fixed from JDK 21 onwards, not able to reproduce it from JDK 21 and further.
29-05-2024

I guess the problem described in the description is about the swing text component, which is drawn by Swing itself.
26-03-2020

It is seen in jdk9 and jdk10 too. The visual appearance are under the control of the desktop's window management system. The visual effects as shadows, motion effects, animations, and others may not be controlled by the applications but work according to the desktop settings so it probably may not be fixed.
26-03-2020

Per description, borders of Swing components are intermittently painted too thick with Windows-LAF on HiDPI screens with scaling > 100%. Checked this with reported version 11.0.6 and could observe the difference w.r.t borders outlook. Configuration: Windows 10, JDK 11.0.6, 14, 8u241 WQHD, 125%+ scaling Result: ============= 8u241: na 11.0.6: Fail 14: Fail 15: Fail To verify, run the attached test case. For details refer to attached screenshots. Ref: https://github.com/apache/netbeans/pull/1777
25-03-2020