public class Tes

{

   static TestField tf1;static TestField tf2;static Choice choice;static TestField tf3;

  public static void main(String[]args)

{

  Frame frame=new Frame("计算器");

frame.setSize(300,200);

frame.setLocation(300,200);

frame.addWindowListener(new Listener());

final TestField tf1=new TestField(8);

final Choice choice=new Choice();

choice.addItem("+");

choice.addItem("-");

choice.addItem("*");

choice.addItem("/");

final TestField tf2=new TestField(8);

Lable lable =new Lable("=");

final TestField tf3=new TestField(8);

Button button=new Button("计算器");

frame.add(tf1);

frame.add(choice);

frame.add(tf2);

frame.add(Lable);

frame.add(tf3);

frame.add(button);

frame.setLayout(new flowLayout());

{

@override

public void actionperformed(ActionEvent argo)

{

String s1=tf1.get Test();

String s2=tf2.getTest();

String ch=Choice.getSelectedItem();

double d1=Double.parseDouble(s1);

double d2=Double.parseDouble(s2);

double d=0;

if(ch.equals("+"))

{

d=d1+d2;

}

else if(ch.equals("-"))

{

d=d1*d2;

}

else

{

d=d1/d2;

}

tf3.setTest(d+"");

}

})

frame.setVisible(true);

}

}