| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 495 人关注过本帖
标题:集合 序列化 加 反序列化 到 JTable!!!!!!!!!!!!!!!!!!! ...
只看楼主 加入收藏
xe569886048
Rank: 2
等 级:论坛游民
威 望:1
帖 子:59
专家分:28
注 册:2009-10-9
结帖率:66.67%
收藏
 问题点数:0 回复次数:1 
集合 序列化 加 反序列化 到 JTable!!!!!!!!!!!!!!!!!!!!!
package xitong;
import java.awt.*;
import *;
import java.util.ArrayList;
import java.util.Vector;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
public class ZJhy extends JFrame{
    private static final Object[][] DefaultTableModel = null;
    JFrame jf1;
    JPanel jp1;
    JButton jb1,jb2,jb3,jb4;
    JTable jt1;
    JScrollPane jsp1;
   
   
   
   
    String biaoti[]={"姓名","年龄","性别","等级"};
     
    String xe1[];
   
   
    public ZJhy(){
        
        
        FileInputStream shuru;
        try {
            shuru = new FileInputStream("系统信息库"+"/"+"huiyuan.bat");
            try {
                ObjectInputStream dx1=new ObjectInputStream(shuru);
               
               
               
               
                ArrayList<huiyuan> hy=new ArrayList<huiyuan>();
                try {
                    
                    // tableModel      aa=new DefaultTableModel;
                    huiyuan xe;
                    hy=(ArrayList<huiyuan>) dx1.readObject();
                    for(int a=0;a<hy.size();a++){
                        String DefaultTableModel =hy.get(a).getName()+","+hy.get(a).getAge()+","+hy.get(a).getSex()+","+hy.get(a).getDj();
                    
                    }
                    
                    
                } catch (ClassNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
               
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        
        
        
        jf1=new JFrame("增加会员");
        jp1=new JPanel();
        
        
        jb1=new JButton("增加");
        jb1.addActionListener(new ActionListener(){

            @Override
            public void actionPerformed(ActionEvent arg0) {
                new hyzj();
               
            }
            
        });
        jb2=new JButton("修改");
        jb3=new JButton("删除");
        jb4=new JButton("查看");
        
        jp1.add(jb1);
        jp1.add(jb2);
        jp1.add(jb3);
        jp1.add(jb4);
        jp1.setBounds(0,250,400,50);
        
        jt1=new JTable(DefaultTableModel,biaoti);
        
        
        jsp1=new JScrollPane(jt1);
        jsp1.setBounds(0,0,400,250);
        
        //this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        
        
        
        
        
        jf1.add(jp1);
        jf1.add(jsp1);
        jf1.setSize(420,320);
        jf1.setLayout(null);
        jf1.setDefaultCloseOperation(this.HIDE_ON_CLOSE);
        jf1.setTitle("会员管理");
        jf1.setVisible(true);
        
        
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        new ZJhy();
        

    }

}
搜索更多相关主题的帖子: 姓名 private package Object 
2011-08-23 21:22
husiwen
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:2
帖 子:227
专家分:1125
注 册:2010-5-23
收藏
得分:0 
。。。
2011-08-23 22:06
快速回复:集合 序列化 加 反序列化 到 JTable!!!!!!!!!!!!!!!! ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034936 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved