java计算器代码(国外英文资料).doc
文本预览下载声明
java计算器代码(国外英文资料)
进口java.awt。*;
进口java.awt.event。*;
类leiyi扩展框架{
静态双con1 = 0;
静态int jihao = 0;
静态int肖= 0;
静态int jishu = 10;
私人按钮button1 = new按钮(“7”);
私人按钮button2 = new按钮(8);
私人按钮button3 = new按钮(“9”);
私人按钮button4 = new按钮(“+”);
私人按钮button5 = new按钮(4);
私人按钮button6 = new按钮(“5”);
私人按钮button7 = new按钮(“6”);
私人按钮button8 = new按钮(“-”);
私人按钮button9 = new按钮( 1 );
私人按钮button10 = new按钮(“2”);
私人按钮button11 = new按钮(“3”);
私人按钮button12 = new按钮( = );
私人按钮button13 = new按钮(“*”);
私人按钮button14 = new按钮(“/”);
私人按钮button15 = new按钮(“0”);
私人按钮button16 = new按钮(“CE”);
私人按钮button17 = new按钮(“。”);
私人按钮button18 = new按钮(“根”号);
私人按钮button19 = new按钮(“平方”);
私人TextArea textarea1 = new TextArea(“0”);
公共leiyi()
{
超级(“小小计算器”);
/ / GridLayout card1 = new GridLayout(5、4、5、5);
/ / setLayout(card1);
setLayout(空);
textarea1.setBounds(10、40270、50);
button1.setBounds(90、50、50);
button2.setBounds(85、90、50,50);
button3.setBounds(155、90、50,50);
button4.setBounds(225、90、50,50);
button5.setBounds(15145年,50,50);
button6.setBounds(85145年,50,50);
button7.setBounds(155145年,50,50);
button8.setBounds(225145年,50,50);
button9.setBounds(15200年,50,50);
button10.setBounds(85200年,50,50);
button11.setBounds(155200年,50,50);
button12.setBounds(225200、50105);
button13.setBounds(15255年,50,50);
button14.setBounds(85255年,50,50);
button15.setBounds(155255年,50,50);
button16.setBounds(225310年,50,50);
button16.setForeground(Color.red);
button16.setBackground(Color.pink);
button17.setBounds(15310年,50,50);
button18.setBounds(85310年,50,50);
button19.setBounds(155310年,50,50);
添加(button1);
添加(button2);
添加(button3);
添加(button4);
添加(button5);
添加(button6);
添加(button7);
添加(button8);
添加(button9);
添加(button10);
添加(button11);
添加(button12);
添加(button13);
添加(button14);
添加(button15);
添加(button16);
添加(textarea1);
添加(button17);
添加(button18);
添加(button19);
button1。addActionListener(新ActionListener()
{公共空actionPerformed(ActionEvent e)
{
如果(肖= = 0)
{ tmp1 = textarea1字符串。
getText();
双a2 = Double.parseDouble(tmp1);
双a3 = a2 * 10 + 7.0;
字符串tmp4 = String.valueOf(a3);
显示全部