Java JComboBox Value fillValue(Vector vtData, int iComboIndex, int iVectorIndex, JComboBox cbo, Vector vt, boolean bClear, boolean bHaveNull)

Here you can find the source of fillValue(Vector vtData, int iComboIndex, int iVectorIndex, JComboBox cbo, Vector vt, boolean bClear, boolean bHaveNull)

Description

fill Value

License

Apache License

Parameter

Parameter Description
vtData Vector
iComboIndex int
iVectorIndex int
cbo JComboBox
vt Vector
bClear boolean
bHaveNull boolean

Exception

Parameter Description
Exception an exception

Declaration

public static void fillValue(Vector vtData, int iComboIndex, int iVectorIndex, JComboBox cbo, Vector vt,
        boolean bClear, boolean bHaveNull) throws Exception 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.*;
import javax.swing.*;

public class Main {
    /**//from w w  w. j  av a  2 s  .  c  o m
     *
     * @param vtData Vector
     * @param iComboIndex int
     * @param iVectorIndex int
     * @param cbo JComboBox
     * @param vt Vector
     * @param bClear boolean
     * @param bHaveNull boolean
     * @throws Exception
     */
    public static void fillValue(Vector vtData, int iComboIndex, int iVectorIndex, JComboBox cbo, Vector vt,
            boolean bClear, boolean bHaveNull) throws Exception {
        // Clear
        if (bClear) {
            vt.clear();
            cbo.removeAllItems();
        }

        // Add null value
        if (bHaveNull) {
            vt.addElement("");
            cbo.addItem("");
        }

        // Fill value
        for (int iRowIndex = 0; iRowIndex < vtData.size(); iRowIndex++) {
            Vector vtResultRow = (Vector) vtData.elementAt(iRowIndex);
            vt.addElement(vtResultRow.elementAt(iVectorIndex));
            cbo.addItem(vtResultRow.elementAt(iComboIndex));
        }
    }

    /**
     *
     * @param vtData Vector
     * @param cbo JComboBox
     * @param vt Vector
     * @param bClear boolean
     * @param bHaveNull boolean
     * @throws Exception
     */
    ////////////////////////////////////////////////////////
    public static void fillValue(Vector vtData, JComboBox cbo, Vector vt, boolean bClear, boolean bHaveNull)
            throws Exception {
        fillValue(vtData, 1, 0, cbo, vt, bClear, bHaveNull);
    }

    public static void fillValue(Vector vtData, JComboBox cbo, Vector vt) throws Exception {
        fillValue(vtData, cbo, vt, true, false);
    }
}

Related

  1. containsValue(JComboBox comboBox, String value)
  2. createComboBox(ActionListener actionListener, Vector values, String command)
  3. createComboBox(final Preferences node, final String pref_name, final String[] options, final String default_value)
  4. createStandardCombo(String[] values)
  5. getCmbValue(JComboBox cmb)
  6. getDouble(javax.swing.JComboBox input)
  7. getIfHasValue(Object val, JComboBox cb)
  8. getInt(JComboBox combo)