Here is how I have done it in the past, it isnt lightning quick as it relies on string comparisons, but then it really doesnt matter if youre just setting a few items
cb = ((com.sun.lwuit.ComboBox ) findByNameX("insurance_companycb", frm ));
int index = getIndexOfThisString(cb,RegistrationInfoContainer.insurance_company,"updatingProfile a");
setSelectedIndexOfComboBox(cb,index);
//pass in a string and a comboxbox and get back the index of that string within the combobox
private int getIndexOfThisString(ComboBox cb, String myString,String whoCalled)
{
_("getIndexOfThisString called by "+whoCalled);
ListModel lm = cb.getModel();
for (int i=0; i<lm.getSize(); i++)
{
String s = lm.getItemAt(i).toString();
if (s.equals(myString))
{
return i;
}
}
showError("getIndexOfThisString (for cb "+cb.getName()+") has failed to find the index of "+myString);
return -1;
}
private void setSelectedIndexOfComboBox(ComboBox cb, int index)
{
_("setSelectedIndexOfComboBox "+cb.getName());
if (index>=0)
{
cb.setSelectedIndex(index);
}
else
{
_("WARNING.................... setSelectedIndexOfComboBox got -1 so cant set index!!!");
}
}