private void setSelectedItem ( final ListBox list , final String item ) { final int nitems = list . getItemCount ( ) ; for ( int i = 0 ; i < nitems ; i ++ ) { if ( item . equals ( list . getValue ( i ) ) ) { list . setSelectedIndex ( i ) ; return ; } } }
If the given item is in the list mark it as selected .