java课程设计-家庭理财系统。。 第一个小作品

源代码在线查看: table.java

软件大小: 2859 K
上传用户: jl315
关键词: java
下载地址: 免注册下载 普通下载 VIP

相关代码

				/**
				 *此Table.class用于测试,,程序的表我放在Monneymanager.class中。。。 
				 
				 *
				 */
				
				import   javax.swing.table.AbstractTableModel;   
				  import   javax.swing.*;   
				  import   java.awt.GridLayout;   
				  import   java.awt.Dimension; 
				    
				     class   Table   extends   JPanel   { 
					  
					
					  
				          /**
						 * 
						 */
						private static final long serialVersionUID = 1L;
				
						public   Table()   {   
				                  JTable   table   =   new   JTable(new   MyTableModel()); 
				                  
				                  table.setModel(new MyTableModel()); 
				
				                  table.updateUI(); 
				
				                 
				                  JScrollPane   scrollPane   =   new   JScrollPane(table);   
				                  scrollPane.setPreferredSize(new   Dimension(800, 40));
				                  setLayout(new   GridLayout(1,   0));     
				                  add(scrollPane);  
				          }
				                  
				                  }
				                                  
				    
				    
				          class   MyTableModel   extends   AbstractTableModel   { 
				        	  
				        	       
				 
				
				                  /**
							 * 
							 */
							private static final long serialVersionUID = 1L;
								final   String[]   columnNames   =   {"序号","收入",  "支出", "时间", "备注"};   
				                    final static String[][]   data   =   { {},{},{}}  ;
				                  
				                  
				                	   
				                	  
				                  
				                  
				                                                       
				                  public   int   getColumnCount()   {   
				                          //return   columnNames.length;  
				                          return 5;
				                  }   
				    
				                  public   int   getRowCount()   {   
				                         return   data.length; 
				                          //return  100;
				                        
				                  }   
				    
				                  public   String   getColumnName(int   col)   {   
				                          return   columnNames[col];   
				                  }   
				    
				                  public   Object   getValueAt(int   row,   int   col)   {  
				                	  
				                	  
				                     // return   data[row][col]; 
				                	  
				                 return   ""+row+","+col;   
				             }   
				             
				  
				          
				          public   static   void   main(String[]   args)   {   
				                  
				        	 new Table();
				        	
				          }   
				  }
							

相关资源