当前位置: 首页 > news >正文

荆州市城市建设投资开发有限公司网站百度人工服务24小时

荆州市城市建设投资开发有限公司网站,百度人工服务24小时,微网站做下载链接,建设手机网站费用我需要添加一个“清除计算器”的按钮,以及一个退出butPanel上的程序的按钮.它也需要是非常基本的Java代码,因为我是初学者,并且有一个糟糕的comp.sci.老师.我有一个带退出按钮的代码示例,但我不确定如何将它放入我的程序中.我已经尝试了这么多.此外,如果有一个更好的“错误检查…我需要添加一个“清除计算器”的按钮,以及一个退出butPanel上的程序的按钮.它也需要是非常基本的Java代码,因为我是初学者,并且有一个糟糕的comp.sci.老师.我有一个带退出按钮的代码示例,但我不确定如何将它放入我的程序中.我已经尝试了这么多.此外,如果有一个更好的“错误检查”方式,将非常感激.import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Calculator2 extends JFrame implements ActionListener{JLabel heading new JLabel (2. Calculator);JLabel intro1 new JLabel (This program stimulates a four-function calculator.);JLabel intro2 new JLabel (It takes an operator and a number. It can add, subtract,);JLabel intro3 new JLabel ( multiply and divide. Enter in the format eg. 35. );JLabel inLabel new JLabel ( Operation: );JLabel outLabel new JLabel ( Total: );JTextField inOper new JTextField (7);JTextField outTota new JTextField (7); // intro//panelsJPanel titlePanel new JPanel ();JPanel intro1Panel new JPanel ();JPanel intro2Panel new JPanel ();JPanel intro3Panel new JPanel ();JPanel operPanel new JPanel ();JPanel totaPanel new JPanel ();JPanel butPanel new JPanel ();String operTemp;String totaTemp;public Calculator2 (){setTitle (C - 2.);inOper.addActionListener (this);outTota.setEditable (false);getContentPane ().setLayout (new FlowLayout ());titlePanel.add (heading);intro1Panel.add (intro1);intro2Panel.add (intro2);intro3Panel.add (intro3);operPanel.add (inLabel);operPanel.add (inOper);totaPanel.add (outLabel);totaPanel.add (outTota); //adds components to panelsgetContentPane ().add (titlePanel);getContentPane ().add (intro1Panel);getContentPane ().add (intro2Panel);getContentPane ().add (intro3Panel);getContentPane ().add (operPanel);getContentPane ().add (totaPanel); //Adds panels to FramesetDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);}public static int isInteger (String input){try{Integer.parseInt (input);return Integer.parseInt (input);}catch (NumberFormatException nfe){return 0;}} //isInteger method// The applicationpublic String calculate (String operation, String newtotal){int total isInteger (newtotal);String totalS;char operator;int number 0;operator operation.charAt (0);if (operator ){number isInteger (operation.substring (1));total total number;totalS Integer.toString (total);}else if (operator -){number isInteger (operation.substring (1));total total - number;totalS Integer.toString (total);}else if (operator *){number isInteger (operation.substring (1));total total * number;totalS Integer.toString (total);}else if (operator /){number isInteger (operation.substring (1));total total / number;totalS Integer.toString (total);}else{totalS (ERROR);}if (number 0){totalS (ERROR);}return totalS;} // calculate methodpublic void actionPerformed (ActionEvent evt){String userIn inOper.getText ();String totalIn outTota.getText ();try{totaTemp calculate (userIn, totalIn);outTota.setText (totaTemp );}catch (Exception ex){outTota.setText (ERROR);}repaint ();}public static void main (String[] args){Calculator2 calc new Calculator2 ();calc.setSize (350, 350);calc.setResizable (false);calc.setVisible (true);}}
http://www.zqtcl.cn/news/506994/

相关文章:

  • 人才网官方网站公众号排名优化软件
  • 淘宝返利网站建设软件开发哪里学好
  • 烟台网站制作公司如何注册国外网站
  • discuz企业网站网站可以做音频线吗
  • 怎样制作网站教程哪家好制作网页的的网站
  • 网站没有织梦后台无锡seo公司网站
  • 哈尔滨住房和城乡建设厅网站公司网站建设 费用入账
  • 网站图片缩略图t恤图案设计网站
  • 对招聘网站页面设计做建议网站流量 转化率
  • 怎么样做网站注册量郴州市北湖区
  • 山东企业展厅设计公司济南网站建设优化公司
  • 什么网站免费做游戏工艺品外贸订单网
  • 免费推广网站制作网站设计的技术有
  • 深圳电商网站建设高校学风建设专栏网站
  • 品牌网站建设 2蝌蚪小三网合一的网站怎么做
  • 对二次网站开发的认识wordpress修改图片大小
  • 电商网站项目建设个人网站空间收费
  • 官方网站制作思路樟木头东莞网站建设
  • 怎么寻找做有益做网站的客户大连网站推广
  • 湖南网站开发企业excel网站建设
  • 安康网站建设技巧腾讯建设网站视频下载
  • 如何能让企业做网站的打算中企动力做网站贵吗
  • wordpress 空间常州seo
  • 网站负责人备案采集照具体要求湛江网吧
  • 长春建站模板制作php网站空间购买
  • 网站域名到期怎么办食品包装设计的介绍
  • 建设网站专栏台州cms模板建站
  • 网站建设套餐方案湛江网站如何制作
  • wordpress网站怎么打开西安企业做网站多少钱
  • 电子商务网站建设的实训报告网页美工设计夏霍