求高手解答
import java.awt.*;
import java.awt.event.*;
public class MyCalculator implements ActionListener
{
Frame frame;
TextField tf;
Panel p1,p2,p3;
Button b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b_add,b_sub,b_mul,b_div,b_equ,b_point,b_clear,b_ce;
double m=0;
double k=0;
double cur=0;
public MyCalculator()
{
frame=new Frame("欢迎来到java世界");
Toolkit tk=Toolkit.getDefaultToolkit();
Dimension screenSize=tk.getScreenSize();
int screenWidth=screenSize.width;
int screenHeight=screenSize.height;
frame.setSize(360,200);
frame.setLocation(screenWidth/3,screenHeight/3);
frame.setLayout(new BorderLayout());
frame.setBackground(Color.lightGray);
tf=new TextField(30);
tf.setEditable(false);
tf.setBackground(Color.white);
frame.add(tf,BorderLayout.CENTER);
p1=new Panel(new BorderLayout());
frame.add(p1,BorderLayout.SOUTH);
b0=new Button("0");
b0.addActionListener(this);
b1=new Button("1");
b1.addActionListener(this);
b2=new Button("2");
b2.addActionListener(this);
b3=new Button("3");
b3.addActionListener(this);
b4=new Button("4");
b4.addActionListener(this);
b5=new Button("5");
b5.addActionListener(this);
b6=new Button("6");
b6.addActionListener(this);
b7=new Button("7");
b7.addActionListener(this);
b8=new Button("8");
b8.addActionListener(this);
b9=new Button("9");
b9.addActionListener(this);
b_add=new Button(" + ");
b_add.setForeground(Color.RED);
b_add.addActionListener(this);
b_sub=new Button("-");
b_sub.setForeground(Color.RED);
b_sub.addActionListener(this);
b_mul=new Button("*");
b_mul.setForeground(Color.RED);
b_mul.addActionListener(this);
b_div=new Button("/");
b_div.setForeground(Color.RED);
b_div.addActionListener(this);
b_equ=new Button("=");
b_equ.setForeground(Color.red);
b_equ.addActionListener(this);
b_point=new Button(".");
b_point.setForeground(Color.red);
b_point.addActionListener(this);
b_clear=new Button("CE");
b_clear.setForeground(Color.red);
b_clear.addActionListener(this);
p2=new Panel(new FlowLayout(FlowLayout.RIGHT));
p2.add(b_clear);
p2.add(b_add);
p3=new Panel(new GridLayout(3,5,2,2));
p3.add(b1);
p3.add(b2);
p3.add(b3);
p3.add(b4);
p3.add(b_sub);
p3.add(b5);
p3.add(b6);
p3.add(b7);
p3.add(b8);
p3.add(b_mul);
p3.add(b9);
p3.add(b0);
p3.add(b_point);
p3.add(b_equ);
p3.add(b_div);
p1.add(p2,BorderLayout.NORTH);
p1.add(p3,BorderLayout.CENTER);
frame.add(p1,BorderLayout.SOUTH);
frame.addWindowListener(new WinClose());
frame.setVisible(true);
tf.setText(" ");
}
int flag=0;
int num=0;
double dot=0;
double first=0,second=0,result=0;
Boolean push=false;
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b_clear)
{
tf.setText("0");
num=0;
dot=0;
push=false;
flag=0;
first=0;
}
if(e.getSource()==b0)
{
if(push==false)
tf.setText(e.getActionCommand());
else
tf.setText(tf.getText()+e.getActionCommand());