首页>代码>java swing JTable的中级应用>/SwingComponents/src/com/learn/swing/jtable/abstracttablemodel/TableValues.java
                
                package com.learn.swing.jtable.abstracttablemodel;
import javax.swing.table.AbstractTableModel;
/** 
 * TableModel 的实现类
 * 注意:一般使用AbstractTableModel创建TableModel的实现,只有少量数据时使用DefaultTableModel,
 */
@SuppressWarnings("serial")
public class TableValues extends AbstractTableModel{
	private final static int NAME = 0;
	private final static int GENDER = 1;
	private final static int BIRTH = 2;
	private final static String[] columnNames = {"姓名", "性别", "生日"};
	private Object[][] values = {
                       {"Cannel_2020",true,"2012-11-13"},
                       {"Lucy",false,"2013-11-13"},
                       {"韩梅",false,"2014-11-13"},
                       {"李雷",true,"2015-11-13"},
                       {"Jim",true,"2016-11-13"}
    };
    
	@Override
	public int getRowCount() {
		return values.length;
	}
	@Override
	public int getColumnCount() {
		return values[0].length;
	}
	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		return values[rowIndex][columnIndex];
	}
	
    /**
     * 设置单元格可以编辑
     */
    public boolean isCellEditable(int row, int column){
       return true;
    }
    
    /**
     * 单元格被编辑完后,调用此方法更新值
     */
    public void setValueAt(Object value, int row, int column){
    	values[row][column]= value;
    }
	/**
     * 获取列名
     */
    public String getColumnName(int columIndex){
        return columnNames[columIndex];
    }
	public static int getName() {
		return NAME;
	}
	public static int getGender() {
		return GENDER;
	}
	
	public static int getBirth() {
		return BIRTH;
	}
}
 最近下载更多
最近下载更多
                
                wyx065747     LV67
                2022年4月7日
            
            
        
                Demo1111     LV30
                2021年12月12日
            
            
        
                一个好人520     LV10
                2021年9月29日
            
            
        
                yangctz     LV25
                2021年9月10日
            
            
        
                ysc123     LV5
                2021年7月8日
            
            
        
                香菇肉饼汤     LV8
                2020年5月21日
            
            
        
                上善_若水     LV3
                2020年2月19日
            
            
        
                liaozhensy     LV1
                2019年7月18日
            
            
        
                yongzheng132     LV17
                2019年6月21日
            
            
        
                ty93pical     LV2
                2019年4月22日
            
            
         最近浏览更多
最近浏览更多
                
                1219610676     LV4
                2023年12月7日
            
            
        
                ezra77934     LV2
                2023年9月16日
            
            
        
                hufuman     LV23
                2023年4月6日
            
            
        
                漫步的海星     LV4
                2023年3月16日
            
            
        
                2252536772     LV21
                2022年11月9日
            
            
        
                lcb813     LV1
                2022年7月1日
            
            
        
                a318888331     LV13
                2022年5月30日
            
            
        
                忧麦紫     LV18
                2022年3月2日
            
            
        
                zkingzz    
                2021年12月21日
            
            
                    暂无贡献等级
            
        
                Demo1111     LV30
                2021年12月12日
            
            
        
 
                 
                 
                 
                