Java JComboBox Value getIfHasValue(Object val, JComboBox cb)

Here you can find the source of getIfHasValue(Object val, JComboBox cb)

Description

get If Has Value

License

Open Source License

Declaration

private static Object getIfHasValue(Object val, JComboBox cb) 

Method Source Code


//package com.java2s;
import javax.swing.*;

public class Main {
    private static Object getIfHasValue(Object val, JComboBox cb) {

        if (val == null) {
            return null;
        }/*  w w w  . j a v a 2s.c  o  m*/

        String vals = val.toString();
        for (int i = 0; i < cb.getModel().getSize(); i++) {
            if (cb.getModel().getElementAt(i).toString().equals(vals)) {
                return val;
            }
        }

        return null;

    }
}

Related

  1. createComboBox(final Preferences node, final String pref_name, final String[] options, final String default_value)
  2. createStandardCombo(String[] values)
  3. fillValue(Vector vtData, int iComboIndex, int iVectorIndex, JComboBox cbo, Vector vt, boolean bClear, boolean bHaveNull)
  4. getCmbValue(JComboBox cmb)
  5. getDouble(javax.swing.JComboBox input)
  6. getInt(JComboBox combo)
  7. IsComboBoxModified(JComboBox comboBox, Object originalValue)
  8. replaceContents(JComboBox combob, Object[] values)
  9. savePrefs(Preferences prefs, String prefKey, JComboBox combo, String newValidValue)