⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testtablemodel2.java

📁 java2 primer plus一书源程序
💻 JAVA
字号:
/* * TestTableModel2.java * * Created on September 3, 2002, 11:34 AM */package ch17;/** * * @author  Stephen Potts */import java.util.Calendar;import java.util.GregorianCalendar;import javax.swing.table.AbstractTableModel;public class TestTableModel2 extends AbstractTableModel{    public final static int FIRST_NAME = 0;    public final static int LAST_NAME = 1;    public final static int DOB = 2;    public final static int CERTIFICATION = 3;    public final static int SALARY = 4;        public final static boolean PROGRAMMER = true;    public final static boolean INSTRUCTOR = false;        public final static String[] columnHeaders =     {        "First Name", "Last Name", "DOB", "Programmer", "Salary"    };        public Object[][] dataValues =    {        {            "Bush", "Bob",            new GregorianCalendar(1954, Calendar.JULY, 4).getTime(),            new Boolean(INSTRUCTOR), new Float(90000)        },        {            "Ezaguirre", "Art",            new GregorianCalendar(1959, Calendar.DECEMBER, 25).getTime(),            new Boolean(PROGRAMMER), new Float(80000)        },        {            "Jenkins", "Lewellen",            new GregorianCalendar(1961, Calendar.AUGUST, 1).getTime(),            new Boolean(PROGRAMMER), new Float(70000)        },        {            "Wells", "Patricia",            new GregorianCalendar(1965, Calendar.JUNE, 20).getTime(),            new Boolean(INSTRUCTOR), new Float(60000)        },        {            "Fleming", "Terry",            new GregorianCalendar(1953, Calendar.NOVEMBER, 4).getTime(),            new Boolean(INSTRUCTOR), new Float(66000)        },        {            "Tippets", "Rick",            new GregorianCalendar(1959, Calendar.SEPTEMBER, 25).getTime(),            new Boolean(PROGRAMMER), new Float(80000)        },        {            "Hall", "Andy",            new GregorianCalendar(1956, Calendar.DECEMBER, 1).getTime(),            new Boolean(PROGRAMMER), new Float(100000)        },        {            "Gummer", "Steve",            new GregorianCalendar(1967, Calendar.JUNE, 20).getTime(),            new Boolean(INSTRUCTOR), new Float(65000)        }    };        /** Creates a new instance of TestTableModel2 */    public TestTableModel2()    {    }        public int getColumnCount()    {        return dataValues[0].length;    }        public int getRowCount()    {        return dataValues.length;    }        public Object getValueAt(int row, int column)    {        return dataValues[row][column];    }        public String getColumnName(int col)    {        return columnHeaders[col];    }        public Class getColumnClass(int col)    {        Class colDataType = super.getColumnClass(col);        if (col == DOB)            colDataType = java.util.Date.class;        if (col == CERTIFICATION)            colDataType = java.lang.Boolean.class;        if (col == SALARY)            colDataType = Float.class;                return colDataType;    }    }

⌨️ 快捷键说明

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