Java JComboBox Selection safeSelectFirst(JComboBox cb)

Here you can find the source of safeSelectFirst(JComboBox cb)

Description

safe Select First

License

Open Source License

Declaration

protected static void safeSelectFirst(JComboBox cb) 

Method Source Code


//package com.java2s;
import javax.swing.*;

public class Main {
    protected static void safeSelectFirst(JComboBox cb) {
        // imp -- so that somethign is selected at startup -> the act of selection
        // fires the event that does the param setting of value
        if (cb.getModel().getSize() > 0) {
            cb.setSelectedIndex(0);//from  www . j a v a  2 s  .c o  m
        }
    }
}

Related

  1. anySelected(JComboBox box)
  2. getSelectedItem(Object combo)
  3. getSelectedName(JComboBox comboBox)
  4. getSelectedString(JComboBox jcb)
  5. getTypedSelectedItemFromCombo(JComboBox combo)
  6. selectComboBoxItem(JComboBox jComboBox, String name)
  7. selectStringInList(String string, JComboBox list)
  8. selectWithoutNotifyingListeners(JComboBox comboBox, int selectedIndex)
  9. setComboSelection(JComboBox cb, String sel)