Here you can find the source of findComboBoxItemForString(final JComboBox box, final String searchString)
Parameter | Description |
---|---|
box | DOCUMENT ME! |
searchString | DOCUMENT ME! |
public static int findComboBoxItemForString(final JComboBox box, final String searchString)
//package com.java2s; //License from project: LGPL import javax.swing.ComboBoxModel; import javax.swing.JComboBox; public class Main { /**/* w ww.j a v a 2 s. com*/ * DOCUMENT ME! * * @param box DOCUMENT ME! * @param searchString DOCUMENT ME! * * @return DOCUMENT ME! */ public static int findComboBoxItemForString(final JComboBox box, final String searchString) { if ((box != null) && (searchString != null)) { final ComboBoxModel model = box.getModel(); if (model != null) { for (int i = model.getSize(); --i >= 0;) { if (searchString.equals(String.valueOf(model.getElementAt(i)))) { return i; } } } } return -1; } }