吧!!!
class Or1 extends JFrame implements ActionListener
{
JButton yes;
JButton no;
Vector vect;
Input in=new Input("123");
JLabel jl=new JLabel("是否真的插入这条记录");
int tf1i;String tf2s;Date date;String tf4s;String tf5s;int tf6i;
public Or1(String s)
{
super(s);
this.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
dispose();System.exit(0);
}
});
setLayout(null);
yes=new JButton("确定");
no=new JButton("取消");
jl=new JLabel("是否真的插入这条记录??");
this.add(jl);
this.add(yes);
this.add(no);
yes.addActionListener(this);
no.addActionListener(this);
jl.setBounds(10,10,250,30);
yes.setBounds(30,50,60,25);
no.setBounds(110,50,60,25);
this.setSize(250,130);
this.setVisible(false);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==yes)
{
try
{
vect=new Vector(10);
date=new Date(Integer.parseInt(in.tf3.getText().substring(0,3)),
Integer.parseInt(in.tf3.getText().substring(4,5)),Integer.parseInt(in.tf3.getText().substring(6,7)));
tf1i=new Integer(in.tf1.getText());
tf1i=new Integer(Integer.parseInt(in.tf1.getText()));
tf2s=new String(in.tf2.getText());
tf4s=new String(in.tf4.getText());
tf5s=new String(in.tf5.getText());
tf6i=new Integer(in.tf6.getText());
tf6i=new Integer(Integer.parseInt(in.tf6.getText()));
vect.addElement(tf1i);
vect.addElement(tf2s);
vect.addElement(date);
vect.addElement(tf4s);
vect.addElement(tf5s);
vect.addElement(tf6i);
FileOutputStream fos=new FileOutputStream("data.txt");
ObjectOutputStream oos=new ObjectOutputStream(fos);
oos.writeObject(vect);
oos.flush();
oos.close();
}
catch(IOException p)
{
System.out.println(p);
}
catch(NumberFormatException o)
{
System.out.println(o);
}
catch(StringIndexOutOfBoundsException m)
{
System.out.println(m);
}
}
if(e.getSource()==no)
{
this.setVisible(false);
}
}
}