Here you can find the source of setComboSelection(JComboBox cb, String sel)
public static void setComboSelection(JComboBox cb, String sel)
//package com.java2s; // LICENSE: This file is distributed under the BSD license. import java.awt.event.ActionListener; import javax.swing.*; public class Main { public static void setComboSelection(JComboBox cb, String sel) { ActionListener[] listeners = cb.getActionListeners(); for (int i = 0; i < listeners.length; i++) cb.removeActionListener(listeners[i]); cb.setSelectedItem(sel);/* www . j a va 2 s. com*/ for (int i = 0; i < listeners.length; i++) cb.addActionListener(listeners[i]); } }