mybilltablemodel.java

来自「基于 C/S 模式的网上购物系统」· Java 代码 · 共 44 行

JAVA
44
字号
package RegisterAndLogin;
import javax.swing.table.*;
public class MyBilltableModel  extends AbstractTableModel {
	final String[] columnNames={"买方","商品","数量","原价","议价","时间"};
	 final Object[][]data=new Object [20][6]; 
	 public MyBilltableModel()
	 {
		 for(int i=0;i<20;i++)		 
		   for(int j=0;j<6;j++)
			 data[i][j]="";	   
		 
		 
	 }
	 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 void setValueAt(Object value,int row,int col)
	 {
		 data[row][col]=value;
		 fireTableCellUpdated(row, col);
	 }
	 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;
	     }
	 }
}

⌨️ 快捷键说明

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