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

📄 mytablemodel.java

📁 java绘图 java awt 经典绘图的例子,对于初学awt模块的人非常有帮助.
💻 JAVA
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package swing;import java.awt.Color;import javax.swing.table.AbstractTableModel;/** * * @author zhaolin */public class MyTableModel extends AbstractTableModel {    @Override    public String getColumnName(int column) {        return columnNames[column];    }    @Override    public Class<?> getColumnClass(int columnIndex) {        return this.getValueAt(0, columnIndex).getClass();    }    @Override    public boolean isCellEditable(int rowIndex, int columnIndex) {        if(columnIndex==1||columnIndex==4){            return true;        }        return false;    }            private Object[][] data = {        {"Mary", Color.RED,    "Snowboarding", new Integer(5), new Boolean(false)},        {"Alison", Color.BLUE,    "Rowing", new Integer(3), new Boolean(true)},        {"Kathy", Color.BLACK,    "Chasing toddlers", new Integer(2), new Boolean(false)},        {"Mark", Color.CYAN,    "Speed reading", new Integer(20), new Boolean(true)},        {"Angela", Color.YELLOW,    "Teaching high school", new Integer(4), new Boolean(false)}    };    private String[] columnNames = {"First Name",        "Last Name",        "Sport",        "# of Years",        "Vegetarian"    };    public int getRowCount() {        return data.length;    }    public int getColumnCount() {        return columnNames.length;    }    public Object getValueAt(int rowIndex, int columnIndex) {        return data[rowIndex][columnIndex];    }    @Override    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {        data[rowIndex][columnIndex] = aValue;        this.fireTableCellUpdated(rowIndex, columnIndex);    }            }

⌨️ 快捷键说明

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