Here you can find the source of updateComboBoxModel(ComboBoxModel model, List> values)
public static void updateComboBoxModel(ComboBoxModel model, List<?> values)
//package com.java2s; //License from project: Apache License import java.util.List; import javax.swing.ComboBoxModel; import javax.swing.DefaultComboBoxModel; public class Main { public static void updateComboBoxModel(ComboBoxModel model, List<?> values) { DefaultComboBoxModel dcbm = (DefaultComboBoxModel) model; Object selected = dcbm.getSelectedItem(); dcbm.removeAllElements();// ww w. j a v a 2 s . com for (Object e : values) { dcbm.addElement(e); if (e.equals(selected)) { dcbm.setSelectedItem(e); } } } }