I’m not sure I understand the whole problem, but if you just want to have a different value and caption for each item, you should add properties to the ComboBox:
ComboBox cmbTitle = new ComboBox();
cmbTitle.setImmediate(false);
cmbTitle.setHeight("30px");
cmbTitle.setWidth("60px");
cmbTitle.setCaption("Title");
cmbTitle.setInputPrompt("select sex");
[b]
cmbTitle.addContainerProperty("caption", String.class, "");
[/b] // add property
[b]
cmbTitle.setItemCaptionPropertyId("caption");
[/b] // use property for caption
String[] sex = new String[]
{ "G", "F" };
[b]
String[] caps = new String[]
{ "Guy", "Fox" };
[/b] // You might want to adjust these
for (int j = 0; j < sex.length; j++) {
[b]
Item item = cmbTitle.addItem(sex[j]
);
[/b]
[b]
item.getItemProperty("caption").setValue(caps[j]
); // set caption property
[/b]
}
Best Regards,
Marc
Update: Uh, and you probably want to add cmbTitle.setNullSelectionAllowed(false);