Java examples for Swing:JComboBox
JComboBox contains Value
//package com.java2s; import javax.swing.ComboBoxModel; import javax.swing.JComboBox; public class Main { /**/* w w w . j av a 2 s .c o m*/ * @param comboBox * @param value * @return if the comboBox contains the specified value */ public static boolean containsValue(JComboBox comboBox, String value) { ComboBoxModel model = comboBox.getModel(); int size = model.getSize(); for (int i = 0; i < size; i++) { Object element = model.getElementAt(i); if (element.equals(value)) { return true; } } return false; } }