Here you can find the source of comboBoxContains(DefaultComboBoxModel model, Object obj)
Parameter | Description |
---|---|
model | combo box to check |
obj | object to test for |
public static boolean comboBoxContains(DefaultComboBoxModel model, Object obj)
//package com.java2s; //License from project: Open Source License import javax.swing.DefaultComboBoxModel; public class Main { /**//from w w w . ja va 2 s. c om * Checks to see if a JComboBox contains an object. * @param model combo box to check * @param obj object to test for * @return true or false */ public static boolean comboBoxContains(DefaultComboBoxModel model, Object obj) { for (int i = 0; i < model.getSize(); i++) { if (obj.equals(model.getElementAt(i))) { return true; } } return false; } }