import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class HandleEvent implements ActionListener {
     CalculatorWindow window;

    public HandleEvent(CalculatorWindow window) {
        this.window = window;
    }
    public  void show(){
        window.resultShow.setText(" = "+get(window.computer.getResult()));
        window.showTempResult.setText(get(window.computer.getTempResult())+" ");
        window.showOperator.setText(" "+window.computer.getOperator()+" ");
        window.showDataItem.setText(" "+get(window.computer.computerDataItem()));
    }

    public static String get(double r){//返回浮点数的串表示
        String s="";
        Double d=new Double(r);
        long n=d.longValue();//得到r的整数部分
        if(Math.abs(r-n)>0)//取绝对值
            s=""+r;
        else
            s=""+n;//小数部分为0则省略
        return s;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
    }
}
