一个简单的计算器程序,如何实现sin,cos,tan的驱动
这样实现了,但不正确
public void actionPerformed(ActionEvent e)
{
// TODO Auto-generated method stub
Calculator1.this.jtf.setText("");
}
});
/***
* 实现sin,cos,tan 以及 allButton事件驱动按钮
*/
sinButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
double temp = Math.sin(Double.parseDouble(jtf.getText()));
jtf.setText(String.valueOf(temp));
return;
}
});
cosButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
double temp = Math.cos(Double.parseDouble(jtf.getText()));
jtf.setText(String.valueOf(temp));
return;
}
});
tanButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
double temp = Math.tan(Double.parseDouble(jtf.getText()));
jtf.setText(String.valueOf(temp));
return;
}
});
求指点