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

REGRESSION: Change in JComboBox preferred height in JDK5

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.5.0_02"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_02-b09)
      Java HotSpot(TM) Client VM (build 1.5.0_02-b09, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      In previous java versions the minimum height and the preferred height of a JComboBox have been the same value, specifically 22 pixels on my system.
      As of JRE5 these are no returning different values but only with Windows LAF on a WinXP platform. I now get min height 22 but preferred height 26.
      Other look and feels seem to still be okay with min and preferred height the same.
      This change means my layout managers produce different results on JRE1.4 and JRE5. Please make the min and preferred size the same once again.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      With Win XP, windows look and feel and JRE1.4 run the supplied test case. Then try with JRE5 and see different results.

      If you then remove the lookandfeel setting from the code and default to metal you will see that this change has only occured on windows laf.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      min size and preferred size to be the same
      ACTUAL -
      min size and preferred size differs by 4 pixels with Win XP using windows look and feel (works on all others)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JComboBox;
      import javax.swing.UIManager;

      import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;

      public class Test {

          public Test() {
              super();
          }

          public static void main(String[] args) {
              try {
                  UIManager.setLookAndFeel(new WindowsLookAndFeel());
              } catch(Exception e) {
                  // This won't happen if run on windows.
              }
              
              JComboBox combo = new JComboBox();
              System.out.println("The preferred size is " + combo.getPreferredSize());
              System.out.println("The min size is " + combo.getMinimumSize());
              System.out.println("The max size is " + combo.getMaximumSize());
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Create a factory for making now JComboBoxes which will set the preferred size to the minimum size.

      Release Regression From : 1.4.2_05
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.
      ###@###.### 2005-04-14 09:08:29 GMT

            leifs Leif Samuelsson (Inactive)
            jssunw Jitender S (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: