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

TitledBorder label appears cut off on hidpi devices

    Details

    • Subcomponent:
    • Introduced In Version:
      9
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Tested on a Windows 10 Enterprise 1709 system
      For Java 8, this seems to work.
      For Java 11.0.3, the text is cut off.

      A DESCRIPTION OF THE PROBLEM :
      When using a SynthLabelUI for a TitledBorder on a hidpi monitor with a scaling configured, the label can be cut off at the end. The label is not part of the rendered component hierarchy and when painting it, the graphicsConfiguration is not set. Consequently, the font metrics used is not taking care of the default transformation found on the monitor.

      Without the look and feel being set, the bug does not seem to be triggered.

      REGRESSION : Last worked in version 8u202

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Use a monitor scaling of 125% or more. It should not matter whether this is the main monitor or not.
      Compile and start the following program.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The text "CERTIFICATE CERTIFICATE CERTIFICATE CERTIFICATE" should appear.
      ACTUAL -
      The text is cut off, e.g. at 125% the E is not complete. At 200% the E is almost missing completely.

      ---------- BEGIN SOURCE ----------
      package test;

      import java.awt.Dimension;

      import javax.swing.BorderFactory;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.JPanel;
      import javax.swing.UIManager;

      public class TitledBorderLabelTester
      {
         public static void main(String... aArgs)
         {
            new TitledBorderLabelTester().init();
         }

         private void init()
         {
            try
            {
               UIManager.setLookAndFeel("javax.swing.plaf.synth.SynthLookAndFeel");
            }
            catch (Exception e)
            {
               throw new RuntimeException(e);
            }
            JFrame frame = new JFrame("TitledBorderLabelTester");
            buildContent(frame);
            frame.setPreferredSize(new Dimension(500, 150));
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
         }

         private void buildContent(JFrame frame)
         {
            JPanel panel = new JPanel();
            panel.add(new JLabel("Hello"));
            panel.setBorder(BorderFactory.createTitledBorder("CERTIFICATE CERTIFICATE CERTIFICATE CERTIFICATE"));
            frame.getContentPane().add(panel);
         }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      No real workaround found, besides working with subclasses and reflection.

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              psadhukhan Prasanta Sadhukhan
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: