List of usage examples for javax.swing DefaultComboBoxModel getIndexOf
public int getIndexOf(Object anObject)
From source file:shuffle.fwk.gui.EffectChooser.java
public void setSelectedEffect(Effect effect) { String toSelect = null;// w w w. j a v a 2s . c om if (effect != null) { if (shouldRebuild) { refill(); } toSelect = convertToBox(effect.toString()); DefaultComboBoxModel<String> model = (DefaultComboBoxModel<String>) getModel(); if (model.getIndexOf(toSelect) == -1) { shouldRebuild = true; insertItemAt(toSelect, 0); } else { shouldRebuild = false; } } setSelectedItem(toSelect); }
From source file:shuffle.fwk.gui.TypeChooser.java
public void setSelectedType(PkmType type) { String toSelect = null;/*from ww w . j av a 2 s . c o m*/ if (type != null) { if (shouldRebuild) { refill(); } toSelect = WordUtils.capitalizeFully(type.toString()); DefaultComboBoxModel<String> model = (DefaultComboBoxModel<String>) getModel(); if (model.getIndexOf(toSelect) == -1) { shouldRebuild = true; insertItemAt(toSelect, 0); } else { shouldRebuild = false; } } setSelectedItem(toSelect); }