深入浅出JavaSwing程序设计一书的源代码

源代码在线查看: demotable.java

软件大小: 792 K
上传用户: huanghuanl
关键词: JavaSwing 程序设计 源代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				import javax.swing.*;
				import java.awt.*;
				import javax.swing.table.*;
				
				public class DemoTable extends JInternalFrame{
				
				  public DemoTable(){
				  
				    super("Demo Table Structure", true, true, true, true);
				    
				    TableModel tm = new AbstractTableModel(){
				      String data[][]={
				      	{"Erick","70.0","65.2","92.4","67.6"},
				      	{"Tom"  ,"80.0","75.2","82.4","87.6"},
				      	{"Su"   ,"60.0","75.2","72.4","77.6"},
				      	{"Jimmy","50.0","65.2","82.4","47.6"},
				      	{"Jack" ,"90.0","85.2","62.4","67.6"}
				      };
				      String headers[] ={"","Chinese","English","Ecomonics","Math"};
				      public int getColumnCount(){return headers.length;}
				      public int getRowCount(){return data.length;}
				      public String getColumnName(int col){return headers[col];}
				      public boolean isCellEditable(int row,int col){return true;}
				      public Object getValueAt(int row,int col){return data[row][col];}
				      public void setValueAt(Object value,int row,int col){
				      	data[row][col] = (String)value;
				      	fireTableRowsUpdated(row,row);
				      }      
				    };//end of TableModel
				    
				    JTable jt = new JTable(tm);
				    JScrollPane jsp = new JScrollPane(jt);
				
				    setContentPane(jsp);
				    setSize( 350, 150);
				    setLocation( 150, 20);
				  }//end of DemoTable()
				}//end of class DemoTable			

相关资源