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

REGRESSION: ComboBox height changes on Splitpane resize with Gridbag Layout

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Version:
      5.0
    • Resolved In Build:
      b86
    • CPU:
      x86
    • OS:
      windows_xp

      Backports

        Description

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

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

        A DESCRIPTION OF THE PROBLEM :
        Comboboxes in a panel using gridbag layout will "squash" (resize in height) when the splitpane is resized.

        This is not reproducible without the gridbag layout.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Compile and run the test case provided.
        When the window opens, grab the splitpane and drag to the left.
        Note that the height of the combobox changes (it gets shorter).
        Drag back to the right and notice that the combobox height snaps back to the original size.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The combobox height should not change. This worked properly with the 1.4.2 VM.
        ACTUAL -
        The combobox height changes when the splitpane is moved to the left.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.awt.*;
        import javax.swing.*;

        public class ComboBug extends JFrame
        {
            public ComboBug()
            {
                setTitle("ComboBox Bug Test");

                //---------------LEFT side of splitpane-----------------
                JLabel filesNamedLabel = new JLabel("label1");

                JComboBox combo3 = new JComboBox();
                combo3.insertItemAt("comboitem 1", 0);
                combo3.insertItemAt("comboitem 2", 1);
                combo3.insertItemAt("Browse...", 2);
                combo3.setEditable(true);
                combo3.setLightWeightPopupEnabled(true);
                combo3.setSelectedIndex(0);

                //create a new panel with a gridbag layout.
                GridBagLayout gridbagLookin = new GridBagLayout();
                GridBagConstraints gbcLookin = new GridBagConstraints();
                JPanel lookinPanel = new JPanel(gridbagLookin);

                //add the combobox & label to the panel.
                gbcLookin.insets = new Insets(2, 2, 2, 2);
                gbcLookin.anchor = GridBagConstraints.WEST;
                gbcLookin.fill = GridBagConstraints.HORIZONTAL;

                gbcLookin.gridx = 0;
                gbcLookin.gridy = 0;
                gridbagLookin.setConstraints(filesNamedLabel, gbcLookin);
                lookinPanel.add(filesNamedLabel);

                gbcLookin.gridy = 1;
                gridbagLookin.setConstraints(combo3, gbcLookin);
                lookinPanel.add(combo3);

                //------------RIGHT side of splitpane-----------------
                JPanel emptyPanel = new JPanel(false);
                emptyPanel.setPreferredSize(new Dimension(400, 100));

                //------------Create the splitpane------------------
                JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, lookinPanel, emptyPanel);
                getContentPane().add(splitpane);

                setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                setLocation(200,200);
                pack();
                setVisible(true);
            }

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

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

        Release Regression From : 5.0
        The above release value was the last known release where this
        bug was known to work. Since then there has been a regression.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                jmarinacsunw Joshua Marinacci (Inactive)
                Reporter:
                gmanwanisunw Girish Manwani (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: