Java Utililty Methods JComboBox

List of utility methods to do JComboBox

Description

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

Method

voidsetupComboBoxMaxRows(T inComboBox)
Set the maximum number of rows for a JComboBox so that it always can fit on the screen
BasicComboPopup popup = (BasicComboPopup) inComboBox.getAccessibleContext().getAccessibleChild(0);
JList list = popup.getList();
ListModel lm = list.getModel();
ListCellRenderer renderer = list.getCellRenderer();
int maxItemHeight = 12; 
for (int i = 0; i < lm.getSize(); ++i) {
    Object value = lm.getElementAt(i);
    Component c = renderer.getListCellRendererComponent(list, value, i, false, false);
...
voidupdateContents(@SuppressWarnings("rawtypes") JComboBox box, Object[] options)
update Contents
box.removeAllItems();
for (Object o : options)
    box.addItem(o);
voidupdateGooseChooser(JComboBox gooseChooser, String callingGoose, String[] allGeese)
Updates the UI to show the current list of geese.
if (gooseChooser == null || allGeese == null)
    return;
String savedItem = (String) gooseChooser.getSelectedItem();
Arrays.sort(allGeese);
DefaultComboBoxModel model = (DefaultComboBoxModel) gooseChooser.getModel();
model.removeAllElements();
model.addElement("Boss");
for (String gooseName : allGeese) {
...