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

JLabel ellipsis drawing does not work with display scale 125%

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Windows 11, Java 17.0.12

      A DESCRIPTION OF THE PROBLEM :
      When Windows display scaling 125% is used, JLabel fails to correctly draw the ellipsis ... glyphs when content does not fit the available space.

      The issue seems to be SwingUtilities2.clipString which is using integer char width calculation to spot where available space ends.

      REGRESSION : Last worked in version 8

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run test program with display scale 125%. Resize the window horizontally a little bit.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Ellipsis should be fully visible when content does not fit.
      ACTUAL -
      At times only one or two dots of the ellipsis are visible.

      ---------- BEGIN SOURCE ----------
      public class Jlabelellipsis
      {

      public static void
      main(String[] args)
              throws Exception
      {
      javax.swing.UIManager.put(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
          java.awt.Frame frame = new javax.swing.JFrame("");
          javax.swing.JLabel label = new javax.swing.JLabel("A bunch of text, and so on, etc");
          label.setFont(new java.awt.Font("Arial", java.awt.Font.ITALIC, 11));
          label.setPreferredSize(new java.awt.Dimension(50, 30));
          frame.add(label);
          frame.pack();
          frame.setVisible(true);
      }

      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        1. Jlabelellipsis.java
          0.6 kB
        2. ellipsis.png
          ellipsis.png
          5 kB
        3. jdk24-output.png
          jdk24-output.png
          31 kB

            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: