Package com.nexirius.ulc.example1.datamodel

Source Code of com.nexirius.ulc.example1.datamodel.CodeSelectionModel

package com.nexirius.ulc.example1.datamodel;

import com.nexirius.framework.datamodel.SimpleArrayModel;
import com.nexirius.framework.datamodel.ComboBoxModel;

public class CodeSelectionModel extends ComboBoxModel {
    public static final String[] TEXT_VALUES = new String[] {
        "jnex",
        "for",
        "Swing",
        "HTML",
        "and",
        "ULC",
    };

    public static final String[] CODE_VALUES = new String[] {
        "10001",
        "10002",
        "10003",
        "10004",
        "10005",
        "10006",
    };

    public CodeSelectionModel(int value, String fieldName) {
        super(value, new SimpleArrayModel(TEXT_VALUES), fieldName);
    }

    public String getCode() {
        return CODE_VALUES[getInt()];
    }

    public int setCode(String code) {
        for (int i = 0; i < CODE_VALUES.length; i++) {
            String codeValue = CODE_VALUES[i];

            if (codeValue.equals(code)) {
                setInt(i);
                return i;
            }
        }

        return getInt();
    }
}
TOP

Related Classes of com.nexirius.ulc.example1.datamodel.CodeSelectionModel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.