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

Height of JTextField and JComboBox changed and now different on Win

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • client-libs
    • beta2
    • x86
    • windows_98



      Name: boT120536 Date: 06/03/2001


      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)


      The (default) preferred heights of JTextField and JComboBox have been changed
      between JDK 1.3 and 1.4 beta. This is a problem because:

          (1) Changing these changes the look of existing screens

          (2) At least for Windows look & feel, JTextField and JComboBox should have exactly the same height.

      Here's what happens:

          For Windows look and feel:
              For JDK 1.3: height of JTextField = 21, height of JComboBox = 21
              For JDK 1.4: height of JTextField = 20, height of JComboBox = 24

          For Java look and feel:
              For JDK 1.3: height of JTextField = 21, height of JComboBox = 26
              For JDK 1.4: height of JTextField = 20, height of JComboBox = 29

      Note. Relevant bug reports in the database:
      4199387 - different height in JDK 1.2.2; fixed in 1.3 -- now broken again
      4269430 - 4 added to JComboBox height to fix a different bug -- the culprit?

      Test program:

      import java.io.*;
      import java.awt.*;
      import javax.swing.*;

      public class Test extends JFrame {

          public static void main(String [] args) {

              try {
                  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              } catch (Exception e) {
              }

              final String[] ITEMS = { "First", "Second", "Third" };

              JTextField field = new JTextField("Text Field");
              JComboBox box = new JComboBox();

              Test frame = new Test();
              frame.getContentPane().setLayout(new FlowLayout());
              frame.getContentPane().add(field);
              frame.getContentPane().add(box);

              box.setModel(new DefaultComboBoxModel(ITEMS));

              frame.pack();

              System.out.println("height of JTextField: "
                                 + field.getPreferredSize().height);
              System.out.println("height of JComboBox: "
                                 + box.getPreferredSize().height);

              frame.setVisible(true);
          }
      }
      (Review ID: 125696)
      ======================================================================

            mdavidsosunw Mark Davidson (Inactive)
            bonealsunw Bret O'neal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: