Java编写的计算器程序及源代码 - 编程入门网
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-20
ot;); help.append("2. 单击“+”执行加、“-”执行减、“*”执行乘或“/”执行除。\n"); help.append("3. 键入计算的下一个数字。\n"); help.append("4. 输入所有剩余的运算符和数字。\n"); help.append("5. 单击“=”。\n"); aboutCal = new JMenuItem(" 关于计算器(A)"); aboutCal.addActionListener(this); helpMenu.add(topHelp); helpMenu.add(aboutCal); mainMenu.add(editMenu); mainMenu.add(viewMenu); mainMenu.add(helpMenu); panel.add(mainMenu, BorderLayout.NORTH); panel.add(textAnswer, BorderLayout.CENTER); panel.add(panel1, BorderLayout.SOUTH); panel1.setLayout(new BorderLayout()); textMemory = new JTextField(3); textMemory.setEditable(false); textMemory.setBackground(new Color(217, 217, 217)); labelMemSpace = new JLabel(" "); buttonBk = new JButton("Backspace"); buttonBk.setForeground(new Color(255, 0, 0)); buttonCe = new JButton("CE"); buttonCe.setForeground(new Color(255, 0, 0)); buttonC = new JButton("C"); buttonC.setForeground(new Color(255, 0, 0)); buttonBk.addActionListener(this); buttonCe.addActionListener(this); buttonC.addActionListener(this); panel1.add(panel2, BorderLayout.NORTH); panel2.setLayout(new FlowLayout(FlowLayout.RIGHT)); panel2.add(textMemory); panel2.add(labelMemSpace); panel2.add(buttonBk); panel2.add(buttonCe); panel2.add(buttonC); panel3 = new JPanel(); panel1.add(panel3, BorderLayout.CENTER); button = new JButton[10]; for (int i = 0; i < button.length; i++) { button[i] = new JButton(Integer.toString(i)); button[i].setForeground(new Color(0, 0, 255)); } buttonMC = new JButton("MC"); buttonMC.setForeground(new Color(255, 0, 0)); buttonMR = new JButton("MR"); buttonMR.setForeground(new Color(255, 0, 0)); buttonMS = new JButton("MS"); buttonMS.setForeground(new Color(255, 0, 0)); buttonMAdd = new JButton("M+"); buttonMAdd.setForeground(new Color(255, 0, 0)); buttonDot = new JButton("."); buttonDot.setForeground(new Color(0, 0, 255)); buttonAddAndSub = new JButton("+/-"); buttonAddAndSub.setForeground(new Color(0, 0, 255)); buttonAdd = new JButton("+"); buttonAdd.setForeground(new Color(255, 0, 0)); buttonSub = new JButton("-"); buttonSub.setForeground(new Color(255, 0, 0)); buttonMul = new JButton("*"); buttonMul.setForeground(new Color(255, 0, 0)); buttonDiv = new JButton("/"); buttonDiv.setForeground(new Color(255, 0, 0)); buttonMod = new JButton("%"); buttonMod.setForeground(new Color(0, 0, 255)); buttonSqrt = new JButton("sqrt"); buttonSqrt.setForeground(new Color(0, 0, 255)); buttonDao = |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于Java编写的计算器程序及源代码 - 编程入门网的所有评论