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

Borders are sometimes painted too thick on HiDPI screens with Windows-LAF

    Details

      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


        Attachments

        1. capture01.JPG
          capture01.JPG
          22 kB
        2. capture02.JPG
          capture02.JPG
          25 kB
        3. HiDPITest.java
          2 kB

          Activity

            People

            • Assignee:
              trebari Tejpal Rebari
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated: