JDK-6626713 : Nimbus L&F: JDialog resizing problem with empty JComboBoxes that receive items
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 6u5
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-11-06
  • Updated: 2011-02-16
  • Resolved: 2008-03-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6u10 b13Fixed
Description
FULL PRODUCT VERSION :
java version "1.6.0_05-ea"
Java(TM) SE Runtime Environment (build 1.6.0_05-ea-b04)
Java HotSpot(TM) Client VM (build 1.6.0_05-ea-b04, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Windows XP SP2

A DESCRIPTION OF THE PROBLEM :
In Nimbus, an empty JComboBox has a very low height. When you insert the first item in it, its height grows considerably. If the JComboBox is within a fixed-size JDialog, and the initial size of the dialog is calculated based on the size of the empty combo box, if you insert an item in the combo box the dialog won't expand along with the combo box in order fully accommodate all visual components it contains.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The following description assumes you're using NetBeans to design the JDialog, using GroupLayout as the layout manager.

- Create a non-resizable JDialog and drop a few components on it: JLabels, JTextFields, JButtons and the like. Just don't forget to drop a few JComboBoxes, and make sure they have empty models (i.e. no items);

- Make sure the dialog occupies the minimum possible size while having all components show up completely, i.e. snap all components to their default sizes, and then resize the dialog to enclose all components exactly;

- In the dialog construtor, after the call to [initComponents()], insert a few items in the combo boxes. Run your program and show the dialog. When the dialog gets shown, you will notice that the lower section of the dialog gets a bit clipped. That's because the combo boxes expanded their size when they got new items, and the dialog didn't expand in order to accommodate the extra size. If you include at least one item in each combo box in the Form Designer (this way, they won't have empty models when pack() is called in the end of initComponents()), you will see that the dialog box is displayed with the correct size.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Having the dialog show all the components completely, without any clipping in the bottom section.
ACTUAL -
The dialog doesn't show all the components completely, clipping parts of the components in the lower section. The more combo boxes you have along the vertical axis of the dialog, the more clipping you get in the lower section.

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Creating every JComboBox with at least one item in the dialog designer, so they won't be empty when the dialog's size is calculated upon calling pack() in initComponents().

Comments
EVALUATION This bug has been tracked down to the calculation of the default size of the combo in BasicComboBoxUI. It was using DefaultListCellRenderer. SynthComboBoxUI needs to override this calculation to use the default Synth combo renderer instead.
07-02-2008