这个程序运行起来有3个TextField  想变成1个。就像电脑里的那个计算器一样,一个输入框,大哥大姐帮帮忙import java.applet.*;
import java.awt.*;
import java.awt.event.*;import javax.swing.JButton;
public class UseArithmetic extends Applet  {

 Label prompt,result;
 TextField input1,input2,input3;
 Button  btn0,btn1, btn2, btn3, btn4, btn5, btn6, btn7, btn8, btn9, btn10, btn11, btn12, btn13,btn14,btn15;
 double a=2, b=1,d=3;
String c="";
 public void init( )
 {
 result=new Label("");
 prompt = new Label("输入");
 input1 = new TextField(5);
 input2 = new TextField(5);
 input3 = new TextField(5);   
 btn0= new Button("0");
 btn1= new Button("1");
 btn2= new Button("2");
 btn3= new Button("3");
 btn4= new Button("4");
 btn5= new Button("5");
 btn6= new Button("6");
 btn7= new Button("7");
 btn8= new Button("8");
 btn9= new Button("9");
 btn10= new Button("+");
 btn11= new Button("-");
 btn12= new Button("*");
 btn13= new Button("/");
 btn14=new Button("=");
 btn15=new Button(".");
 add(result);
 add(prompt);
 add(input1);
 add(input2);
 add(input3);
 add(btn0);
 add(btn1);
 add(btn2);
 add(btn3);
 add(btn4);
 add(btn5);
 add(btn6);
 add(btn7);
 add(btn8);
 add(btn9);
 add(btn10);
 add(btn11);
 add(btn12);
 add(btn13);
 add(btn14);
 add(btn15);
 btn0.addActionListener(new BtnActionAdapter());
 btn1.addActionListener(new BtnActionAdapter());
 btn2.addActionListener(new BtnActionAdapter());
 btn3.addActionListener(new BtnActionAdapter());
 btn4.addActionListener(new BtnActionAdapter());
 btn5.addActionListener(new BtnActionAdapter());
 btn6.addActionListener(new BtnActionAdapter());
 btn7.addActionListener(new BtnActionAdapter());
 btn8.addActionListener(new BtnActionAdapter());
 btn9.addActionListener(new BtnActionAdapter());
 btn10.addActionListener(new fuhaoActionAdapter());
 btn11.addActionListener(new fuhaoActionAdapter());
 btn12.addActionListener(new fuhaoActionAdapter());
 btn13.addActionListener(new fuhaoActionAdapter());
 btn14.addActionListener(new denghaoActionAdapter());
 btn15.addActionListener(new BtnActionAdapter());
 }
 class BtnActionAdapter implements ActionListener{
 public void actionPerformed(ActionEvent e)
   {
 if(input2.getText().equals("")){
            
     //input1.setText(((Button) e.getSource()).getLabel());//getLel  为神马要加 是神马意思??
 input1.setText(input1.getText().concat(((Button)e.getSource()).getLabel().trim()));//不知道这公式为神马这么写 但知道他意思了trim是点号
              a =Double.parseDouble(input1.getText());
            
            
              
            } else {            
             input3.setText(input3.getText().concat(((Button)e.getSource()).getLabel().trim()));          
                b = Double.parseDouble(input3.getText());
            }

 }
 }
 class fuhaoActionAdapter implements ActionListener{
 public void actionPerformed(ActionEvent e)
 {
input2.setText(((Button)e.getSource()).getLabel());
c=input2.getText();
 }

 
 }
 class denghaoActionAdapter implements ActionListener{
 public void actionPerformed(ActionEvent e)
 {

 double d=3;
 if(("+".equals(c)) )
 d=a+b;
 else if(("-".equals(c)) )
 d=a-b;
 else if(("*".equals(c)) )
 d=a*b;
 else if(("/".equals(c)) )
  d=a/b;
 result.setText(a+c+b+"="+d);
 
 }

 }}