Here you can find the source of safeSelectFirst(JComboBox cb)
protected static void safeSelectFirst(JComboBox cb)
//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 } } }