Here you can find the source of containsValue(JComboBox comboBox, String value)
Parameter | Description |
---|---|
comboBox | a parameter |
value | a parameter |
public static boolean containsValue(JComboBox comboBox, String value)
//package com.java2s; //License from project: Open Source License import javax.swing.ComboBoxModel; import javax.swing.JComboBox; public class Main { /**// w w w .java 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; } }