Here you can find the source of selectComboBoxItem(JComboBox jComboBox, String name)
public static void selectComboBoxItem(JComboBox jComboBox, String name)
//package com.java2s; //License from project: Apache License import javax.swing.*; import com.google.common.base.Optional; public class Main { public static void selectComboBoxItem(JComboBox jComboBox, String name) { Optional itemToSelect = Optional.absent(); for (int i = 0; i < jComboBox.getItemCount(); i++) { final Object item = jComboBox.getItemAt(i); if (name.equals(item.toString())) { itemToSelect = Optional.of(item); }/*from w ww.ja v a 2 s. com*/ } if (itemToSelect.isPresent()) jComboBox.setSelectedItem(itemToSelect.get()); } }