java计算器程序源代码_第1页
java计算器程序源代码_第2页
java计算器程序源代码_第3页
java计算器程序源代码_第4页
java计算器程序源代码_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、          JLabel welpic =new JLabel (new ImageIcon(icoURL;           getContentPane(.add(infor,BorderLayout.NORTH;           getContentPane(.add(welpic, BorderLayout.CENT

2、ER;           soth.add(quit,BorderLayout.EAST;           soth.add(quck,BorderLayout.WEST;           getContentPane(.add(soth,BorderLayout.SOUTH;F):    

3、;           /pack(使得( 1.Li Leis bedroom is very big.  pack(;          /显示位置设置 ( 3.Li Leis shoes are all under the chair.          Dimension labelSize=welpic.getPreferredS

4、ize(;( 4.The windows of the bedroom are brown.         /鼠标事件点击退出         addMouseListener(new MouseAdapter(         Mr Brown is a very old man.Every morning he goes for a walk in t

5、he park.And he comes home at twelve thirty for his lunch.                But today a police car stops at his house at twelve oclock.Two policemen help him out.One of them says to Mr Browns daughter.”The old man cant find his way i

6、n the park.He asks us to take him home in the car.”              The daughter thanks the policemen.After they leave,she asks her father,”Dad,you go to that park every day.But today,you cant find the way.Whats wrong with you?  

7、;   /*为了解决这个问题,根据短文内容选择正确答案:设计者赋予我们安全地把Runnable对象加入UI事件队列的能力。在本例中,. 我们用可运行对象closerRunner A.twelve B.eleven SwingUtilities.invokeAndWait(wingUtilities.invokeAndWait( D.twevle ten      UI操作,并执行传递给该方法的可运行对象closerRunner的A.bus B.carC.bike D.taxi迎屏幕的关闭操作,应用担负起了显示和关闭欢迎屏幕之

8、间的所有操作。*/     /.A.doesnt want to walk home B.cant find his way home显示停止的时间,运用线程 D.knows the way    ( 4.Mr Browns daughter thinks .线程启动时,    C.he doesnt want to go to the park D.something is wrong with him      

9、              public void run(              A.he cant find the way home B.he wants to go home on footC.he knows the policemen         &

10、#160;             ;10分)     /*  由于Swing是非线程安全的,除非代码在事件分派线程上执行,否则它就不应该影响任何UI组件的状1 态。所谓事件分派线程,就是Swing中负责绘图和事件处理的线程。*/2.My friend Lucy goes home for hevery year with her parents.       

11、60;  public void run(.              try.                 SwingUtilities.invokeAndWait(closeRunner; 5.Its very far,you n      

12、           )用所给词的适当形式填空 (                分)                 ;      setVisible(tr

13、ue; 2. (swim is my favorite sport.3.We must stop and look both ways before      /     (helpchildren,old people or blind people to cross the road.5.People enjoy (livein a house with a lawn and a garden.计算器的界面:1by subway.(对划线部分提问public class Counter extends JFra

14、me  implements ActionListener         String left=""      String right=""      String mid=""       char flag='0' Lin Tao often to school. 

15、0;    Container counterpanel=this.getContentPane(;3. There is a little light in my room      JPanel panel = new JPanel(;      /面板上的控制按钮a little light in your room?       JButton l2=new JButton("2"4.Hi

16、s bike is under the tree. (对划线部分提问      JButton l6=new JButton("6"      JButton l8=new JButton("8"      JButton l9= new JButton("9"      JButton l0= new JButton("0&q

17、uot;      JButton sum= new JButton("+"      JButton sub= new JButton("-"      JButton drv=new JButton("÷"      JButton sqr=new JButton("SQR"me.( 同义句改写 

18、;     JButton ad=new JButton("="I sit Wang Hai.      JMenu jmenufile =new JMenu(;fifteen metres from here. (对划线部分提问      JMenuItem jmenufile_copy =new JMenuItem(;      JMenuItem jmenuhelp_help =n

19、ew JMenuItem(;8.What about playing computer?(同义句改写"      panel.setLayout(new BorderLayout(;10      pane.setLayout(new GridLayout(5,4;        clear.addActionListener(this;      l1.addActionLi

20、stener(this;       l2.addActionListener(this;      l3.addActionListener(this;       l4.addActionListener(this;       l5.addActionListener(this;B:       l7.addActionListener(th

21、is;       l8.addActionListener(this;      l9.addActionListener(this;A:Excuce me. 2       sum.addActionListener(this;      sub.addActionListener(this;      point.addActionListe

22、ner(this;       cos.addActionListener(this;       sin.addActionListener(this;      drv.addActionListener(this;A: 4       back.addActionListener(this;      sqr.addActionListene

23、r(this;(      pane.add(l1;      pane.add(l2;      pane.add(l3;      pane.add(sum;1 2       pane.add(l6;4(填空完成对话(5      pane.add(l0;   &

24、#160;  pane.add(point;      pane.add(ad;       pane.add(drv;  K:Yes,      pane.add(sin;      pane.add(sqr;book,but I cant find it on that       panel.add(clear,Borde

25、rLayout.NORTH;      panel.add(pane,BorderLayout.CENTER;      answer.setHorizontalAlignment(JTextField.RIGHT ;K:      answer.setEditable(false;6 a minute.Its       answer.setFont(f;    &

26、#160;    counterpanel.add(answer,BorderLayout.NORTH;         counterpanel.add(panel,BorderLayout.CENTER;9 it on time.10 1 2      this.setLocation(screensize.width-framesize.width/2,(screensize.height-    &

27、#160;                                                 &

28、#160;                         framesize.height/2;    6 7 8 9 10       jmenufile_past.setText("粘贴"内容提要:    public vo

29、id actionPerformed(ActionEvent e               if(e.getSource(=l1                             mid=mid+"1&

30、quot;               answer.setText(mid;                       if(e.getSource(=l2        &#

31、160;                    mid=mid+"2"               answer.setText(mid;            

32、;           if(e.getSource(=l3                             mid=mid+"3"       

33、60;       answer.setText(mid;                       if(e.getSource(=l4                  &#

34、160;          mid=mid+"4"               answer.setText(mid;                     

35、  if(e.getSource(=l5                             mid=mid+"5"               answer.set

36、Text(mid;                       if(e.getSource(=l6                          

37、0;  mid=mid+"6"               answer.setText(mid;                       if(e.getSource(=l7    &

38、#160;                        mid=mid+"7"               answer.setText(mid;       

39、0;               if(e.getSource(=l8                             mid=mid+"8"   &#

40、160;           answer.setText(mid;                       if(e.getSource(=l9              &

41、#160;              mid=mid+"9"               answer.setText(mid;                 

42、;      if(e.getSource(=l0                             mid=mid+"0"           

43、0;   answer.setText(mid;                       if(e.getSource(=point                     &

44、#160;  String chk=answer.getText(;               if(!chk.equals("0."                          &

45、#160;     if(pit && answer.getText(.length(!=0                                       mid=mid

46、+"."                    answer.setText(mid;                     pit=false;     &

47、#160;                                                  if(e.getSource(

48、=back                      if(answer.getText(.length(!=0                         

49、0;     int len=answer.getText(.length(;                mid=answer.getText(.substring(0,len-1;                answer.setText(mid;&#

50、160;                          int g=mid.indexOf("."              if(g=-1      &#

51、160;                       pit=true;                             

52、             if(e.getSource(=clear                             mid=""       

53、;        answer.setText("0."                       if(e.getSource(=sum                

54、;             flag='+'               pit=true;                left=answer.getText(; 

55、60;             mid=""               answer.setText(""                 

56、0;     if(e.getSource(=sub                             String chk=answer.getText(.trim(;           &

57、#160;     if(chk.equals(""|chk.equals("0."                                    mid=mid+&quo

58、t;-"                   answer.setText(mid;                             

59、;    else                                    flag='-'         

60、          pit=true;                    left=answer.getText(;                 

61、60; mid=""                   answer.setText(""                         

62、0;              if(e.getSource(=tim                             flag='×'    &

63、#160;          pit=true;                left=answer.getText(;               mid=""    

64、;           answer.setText(""                       if(e.getSource(=drv            &#

65、160;                flag='÷出现了对非数字计算问题!"                               

66、  if(e.getSource(=ad                         double res=0;              mid=""    

67、60;         if(!left.equals(""&&!answer.getText(.equals(""                              

68、;   try                   switch(flag                            

69、              case '+':                         right=answer.getText(;       

70、                     res=Double.parseDouble(left + Double.parseDouble(right;                    

71、0;    answer.setText(String.valueOf(res;                          break;               

72、60;      case '-':                         right=answer.getText(;              

73、60;             res=Double.parseDouble(left - Double.parseDouble(right;                         answer.setText(String.va

74、lueOf(res;                          break;                      case '&

75、#215;':                         right=answer.getText(;                     &

76、#160;      res=Double.parseDouble(left * Double.parseDouble(right;                         answer.setText(String.valueOf(res;                         break;             &

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论