United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6626713 Nimbus L&F: JDialog resizing problem with empty JComboBoxes that receive items
JDK-6626713 : Nimbus L&F: JDialog resizing problem with empty JComboBoxes that receive items

Details
Type:
Bug
Submit Date:
2007-11-06
Status:
Resolved
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2008-03-05
Component:
client-libs
OS:
windows_xp
Sub-Component:
javax.swing
CPU:
x86
Priority:
P4
Resolution:
Fixed
Affected Versions:
6u5
Fixed Versions:
6u10 (b13)

Related Reports

Sub Tasks

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.
                                     
2008-02-07



Hardware and Software, Engineered to Work Together