主题:大家来帮忙修改下 !!求高手帮忙!
import java.awt.*;
import java.awt.event.*;
public class test
{
public static void main(String args[])
{
Frame f = new Frame("");
f.setLayout(new FlowLayout());
Button b1=new Button("确定");
Button b2=new Button("退出");
Label l1=new Label("数据1");
Label l2=new Label("数据2");
Label l3=new Label("结果");
TextField t3=new TextField(8);
TextField t1= new TextField(8);
TextField t2= new TextField(8);
f.add(l1);
f.add(t1);
f.add(l2);
f.add(t2);
f.add(l3);
f.add(t3);
f.add(b1);
f.add(b2);
f.addWindowFocusListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
f.pack();
f.setVisible(true);
ActionListener ac = new ActionlHardler();
b2.addActionListener(ac);
}
}
class ActionHandler implements ActionListener
{
public void actionPerformed(ActionEvent e )
{
test t= new test();
int t1=Integer.valueOf(" ");
int t2=Integer.valueOf(" ");
int t3=Integer.valueOf(" ");
t3=t1+t2;
test.t3.setText(" "+t3);
}
}
import java.awt.event.*;
public class test
{
public static void main(String args[])
{
Frame f = new Frame("");
f.setLayout(new FlowLayout());
Button b1=new Button("确定");
Button b2=new Button("退出");
Label l1=new Label("数据1");
Label l2=new Label("数据2");
Label l3=new Label("结果");
TextField t3=new TextField(8);
TextField t1= new TextField(8);
TextField t2= new TextField(8);
f.add(l1);
f.add(t1);
f.add(l2);
f.add(t2);
f.add(l3);
f.add(t3);
f.add(b1);
f.add(b2);
f.addWindowFocusListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
f.pack();
f.setVisible(true);
ActionListener ac = new ActionlHardler();
b2.addActionListener(ac);
}
}
class ActionHandler implements ActionListener
{
public void actionPerformed(ActionEvent e )
{
test t= new test();
int t1=Integer.valueOf(" ");
int t2=Integer.valueOf(" ");
int t3=Integer.valueOf(" ");
t3=t1+t2;
test.t3.setText(" "+t3);
}
}