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

JComboBox too small under Windows LAF

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Java version (OpenJDK):
      openjdk version "17" 2021-09-14 / OpenJDK Runtime Environment Temurin-17+35 (build 17+35) / OpenJDK 64-Bit Server VM Temurin-17+35 (build 17+35, mixed mode, sharing)
      Java version (Oracle):
      openjdk version "19-ea" 2022-09-20 / OpenJDK Runtime Environment (build 19-ea+9-500) / OpenJDK 64-Bit Server VM (build 19-ea+9-500, mixed mode, sharing)

      OS:
      Edition Windows 11 Pro
      Version 21H2
      Installed on ‎06/‎10/‎2021
      OS build 22000.527
      Experience Windows Feature Experience Pack 1000.22000.527.0


      A DESCRIPTION OF THE PROBLEM :
      When not expanded, the text in a non-editable JComboBox gets truncated with ellipses when using the System LAF under Windows 11 and with a display scale of 125%.
      The default LAF is OK and if the scale is 100% this is also OK.
      Observed in Java 17 (termurin) and confirmed still present on Oracle Java 19 ea.
      The appearance is similar to JDK-8179027 which was fixed in JDK 9 and the sample program given in that report still reproduces the problem now.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the code below under Windows 11 and with graphics scaling of 125%. This code was copied verbatim from JDK-8179027 (https://bugs.openjdk.java.net/browse/JDK-8179027)

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The middle combo box should be wide enough to display the text. Note the right-hand box is OK because this is set editable.
      ACTUAL -
      The text is truncated with ellipses. The effect is similar to that reported in JDK-8179027 as https://bugs.openjdk.java.net/secure/attachment/67764/9eab166.PNG

      ---------- BEGIN SOURCE ----------
      import java.awt.FlowLayout;

      import javax.swing.JComboBox;
      import javax.swing.JFrame;
      import javax.swing.JTextField;
      import javax.swing.UIManager;

      public class ComboBoxLab extends JFrame
      {
         public ComboBoxLab()
         {
            setDefaultCloseOperation( EXIT_ON_CLOSE );

            getContentPane().setLayout( new FlowLayout() );

            getContentPane().add( new JTextField( "item 1" ) );

            JComboBox< String > cboRo = new JComboBox< String >( new String[] { "item 1", "item 2", "item 3" } );
            getContentPane().add( cboRo );

            JComboBox< String > cboRw = new JComboBox< String >( new String[] { "item 1", "item 2", "item 3" } );
            cboRw.setEditable( true );
            getContentPane().add( cboRw );

            pack();
            setVisible( true );
         }

         public static void main( String[] args ) throws Exception
         {
            UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
            new ComboBoxLab();
         }

      }

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

      FREQUENCY : always


        1. Capture.PNG
          Capture.PNG
          20 kB
        2. ComboBoxLab.java
          1 kB
        3. scaling_100.png
          scaling_100.png
          4 kB
        4. scaling_125.png
          scaling_125.png
          4 kB
        5. scaling_150.png
          scaling_150.png
          4 kB
        6. Scaling_175.png
          Scaling_175.png
          5 kB

            tr Tejesh R
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: