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

JTextField is doubleheight if editable and has TitledBorder

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.1
    • 1.4.0
    • client-libs
    • hopper
    • x86
    • windows_nt
    • Verified



      Name: bsT130419 Date: 10/19/2001


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

      When creating a JComboBox with both setEditable(true) and
      setBorder(...TitledBorder...), the text area of the combobox
      is resized to x2 the preferred size. This is related to one
      half of bug 4412467, regarding only the Metal L&F.

      Here's a program that demonstrates the problem, and the workaround.
      The middle combobox is the buggy one.

      -----------------
      package bug;

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

      public class combobug extends JFrame {
          public static void main(String[] argv) {
              new combobug();
          }

          public combobug() {
              super("ComboBug");

              GridBagLayout gridbag = new GridBagLayout();
              GridBagConstraints con = new GridBagConstraints();
              JPanel holdAll = new JPanel(gridbag);

              con.fill = GridBagConstraints.NONE;

              String[] combo1Strings = { "This", "has", "no", "border" };
              JComboBox combo1 = new JComboBox(combo1Strings);
              combo1.setEditable(true);
              gridbag.setConstraints(combo1, con);
              holdAll.add(combo1);

              String[] combo2Strings = { "This", "has", "a titled", "border" };
              JComboBox combo2 = new JComboBox(combo2Strings);
              combo2.setEditable(true);
              combo2.setBorder(BorderFactory.createTitledBorder("Double Height"));
              gridbag.setConstraints(combo2, con);
              holdAll.add(combo2);

              String[] combo3Strings = { "This", "has", "a titled", "border",
                                         "and", "a holding", "JPanel" };
              JComboBox combo3 = new JComboBox(combo3Strings);
              combo3.setEditable(true);
              JPanel workaround = new JPanel();
              workaround.setBorder(BorderFactory.createTitledBorder("Workaround"));
              workaround.add(combo3);
              gridbag.setConstraints(workaround, con);
              holdAll.add(workaround);

              getContentPane().add(holdAll);
              pack();
              setVisible(true);

              addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) { System.exit(0); }
              });
          }
      }
      (Review ID: 134073)
      ======================================================================

            peterz Peter Zhelezniakov
            bstrathesunw Bill Strathearn (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: