public void setSelected ( String s ) { for ( int i = 0 ; i < listBox . getItemCount ( ) ; i ++ ) { if ( listBox . getItemText ( i ) . equals ( s ) ) listBox . setSelectedIndex ( i ) ; } }
Given a string will find an item in the list box with matching text and select it .