jmlistmodel.java.svn-base

来自「梦界家园程序开发基底框架」· SVN-BASE 代码 · 共 78 行

SVN-BASE
78
字号
package jm.framework.gui.module;

import javax.swing.DefaultListModel;

import jm.util.JM2DArray;

/**
 * <p>Title: JM 整合Swing控件,使用配置信息</p>
 *
 * <p>Copyright: Copyright (c) 2004-2006</p>
 *
 * <p>Company: 1SHome</p>
 *
 * <p>@author Spook</p>
 *
 * @since 1.3
 * @see JDK 1.5.0.6
 */
public class JMListModel extends DefaultListModel {
    JM2DArray DataSource = null;
    public JMListModel () {
        super();
    }

    public JMListModel (JM2DArray data) {
        super();
        DataSource = data;
    }

    /**
     * Returns the value at the specified index.
     *
     * @param index the requested index
     * @return the value at <code>index</code>
     * @todo Implement this javax.swing.ListModel method
     */
    public Object getElementAt (int index) {
        if (DataSource == null) {
            return super.getElementAt(index);
        }
        try {
            return DataSource.getStringValue(index, 1);
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * Returns the code at the specified index.
     *
     * @param index the requested index
     * @return the value at <code>index</code>
     * @todo Implement this javax.swing.ListModel method
     */
    public String getElementCodeAt (int index) {
        if (DataSource == null) {
            return ""+index;
        }
        try {
            return DataSource.getStringValue(index, 0);
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * Returns the length of the list.
     *
     * @return the length of the list
     * @todo Implement this javax.swing.ListModel method
     */
    public int getSize () {
        if (DataSource == null) {
            return super.getSize();
        }
        return DataSource.rowCount();
    }

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?