ComboBox Width Issue?

Hey All:
I’m having an issue with the width of a ComboBox. Either I found a bug, or I’m missing something (and given the number of people that probably use the ComboBox, I’m guessing it’s I’m missing something).

I am building a form on a GridLayout. Here is the segment from the create field for the box:

		if ( "status".equalsIgnoreCase(pid)) {
			ComboBox status = new ComboBox("Project Status:");
			String propValue = (String)item.getItemProperty(pid).getValue();			
			for (KeyValuePair pair : ProjectStatus.BuildKeyPair())
			//	status.setItemCaption(pair.getKey(), pair.getValue());				
			return status;

Here is the attach call in the attachfield:

			else if ("status".equals(propertyId))
				layout.addComponent(field, 0,1,2,1);

As you can see, the setItemCaption is commented out (btw: I couldn’t get it to add the items using the bean keyvaluepair directly, I was getting the address location of the object – but that is not the issue).

When I add the item using pairl.getValue() the width of the combox box is the appropriate length. however, when I add the item as the key and do set caption (so that I can reference the keys later and use meaningful words for the end user of the UI), the length of the combo box is short.

is there any way to resize the combo box? I don’t want to do a “setWidth” and manually do it. I’d like the site to be adjusted based on the caption itself.

Am I missing something?

Thanks in advance.

For the item captions, missing/incorrect equals()/hashCode() methods for the key objects might be the issue.

For the length, the combo box cannot take all items into account - there could be thousands of them. When opening the popup, its width is adjusted based on the initially visible items. Without checking the source code, I cannot recall how the width of the combo box itself is calculated if undefined (maybe based on the initially selected item width, or just some default), but is it really inconsistent between different ways of setting the same captions?

I fully agree, that from a length perspective, it would be somewhat (and hopefully this isn’t taken the wrong way) silly to show all.

But attached is the screen shot of the different modes.

As you will see the one with a “caption” defined is smaller than the one with no-caption defined.

My expectation is they would be the same size, even if they were both smaller.

Just thought I would bump this up to the top to see if:

  1. I should put an enhancement request in to make the length of the caption drive the width of the combo box (this should be easily tracked by each addItem and/or setItemCaption that takes place when building the combo box – I guess I’m assuming that’s sort of how it is done now).

  2. if this is a bug and a ticket can be created?

  3. there are other thoughts that this shouldn’t matter?