Java Utililty Methods JComboBox Selection

List of utility methods to do JComboBox Selection

Description

The list of methods to do JComboBox Selection are organized into topic(s).

Method

booleansetComboxSelectItem(JComboBox cb, String s)
set Combox Select Item
int num = cb.getItemCount();
if (s == null || num < 1)
    return false;
String v = (String) cb.getSelectedItem();
if (v.equals(s))
    return false;
for (int i = 0; i < num; i++) {
    v = (String) cb.getItemAt(i);
...
voidsetListData(final JComboBox box, final Collection items, final E selected)
set List Data
box.removeAllItems();
if (items != null) {
    for (E o : items) {
        box.addItem(o);
    if (selected != null && !items.contains(selected)) {
        box.addItem(selected);
booleansetSelectedHeadersaveFileTypeItem(JComboBox combo, int fileType)
set Selected Headersave File Type Item
boolean rv = false;
for (String s : headersaveFileTypeItems) {
    if (!s.isEmpty()) {
        if (s.charAt(0) == fileType) {
            combo.setSelectedItem(s);
            rv = true;
            break;
return rv;
voidupdateContents(@SuppressWarnings("rawtypes") JComboBox box, Object[] options, int selectedIndex)
update Contents
updateContents(box, options);
box.setSelectedIndex(selectedIndex);