集合 序列化 加 反序列化 到 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();
}
}