📄 tablemodel.java
字号:
package net.aetherial.gis.jiaotongbu.outputJTB.txtOutput.view.scan;
import javax.swing.table.AbstractTableModel;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class TableModel extends AbstractTableModel{
public TableModel() {
}
private boolean dataEdit = true;
private String[] columnNames = {"名称","对应的文件"};
// private Object[][] data = {{"array/cun","E:\\...\\cun.txt"},{"表1-乡镇","E:\\...表一乡镇基本信息.xls"}};//same as before...
private Object[][] data = {};
public void getdata(){
}
public Object[] getRow(int row){
return data[row];
}
public void setData(Object[] row){
this.data[0] = row;
}
public void addData(Object[] rowData){
if (this.data.length == 0) {
this.data = new Object[1][2];
this.data[0] = rowData;
}else{
Object[][] temp = new Object[this.data.length+1][2];
temp[0] = rowData;
for (int i = 0; i < this.data.length; i++) {
temp[i+1] = this.data[i];
}
this.data = temp;
}
}
public void removedData(){
this.data = null;
this.data = new Object[0][2];
}
private void printData(){
}
public void setDataEdited(){
this.dataEdit = true;
}
public boolean getDataEdit(){
return this.dataEdit;
}
public int getColumnCount() {
return columnNames.length;
}
public int getRowCount() {
return data.length;
}
public String getColumnName(int col) {
return columnNames[col];
}
public Object getValueAt(int row, int col) {
return data[row][col];
}
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
/*
* Don't need to implement this method unless your table's
* editable.
*/
public boolean isCellEditable(int row, int col) {
//Note that the data/cell address is constant,
//no matter where the cell appears onscreen.
//
// if (col < 2) {
// return false;
// } else {
// return true;
// }
return false;
}
/*
* Don't need to implement this method unless your table's
* data can change.
*/
public void setValueAt(Object value, int row, int col) {
data[row][col] = value;
fireTableCellUpdated(row, col);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -