Java JComboBox Selection setComboSelection(JComboBox cb, String sel)

Here you can find the source of setComboSelection(JComboBox cb, String sel)

Description

set Combo Selection

License

BSD License

Declaration

public static void setComboSelection(JComboBox cb, String sel) 

Method Source Code

//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]);
    }
}

Related

  1. getTypedSelectedItemFromCombo(JComboBox combo)
  2. safeSelectFirst(JComboBox cb)
  3. selectComboBoxItem(JComboBox jComboBox, String name)
  4. selectStringInList(String string, JComboBox list)
  5. selectWithoutNotifyingListeners(JComboBox comboBox, int selectedIndex)
  6. setComboxSelectItem(JComboBox cb, String s)
  7. setListData(final JComboBox box, final Collection items, final E selected)
  8. setSelectedHeadersaveFileTypeItem( JComboBox combo, int fileType)
  9. updateContents( @SuppressWarnings("rawtypes") JComboBox box, Object[] options, int selectedIndex)