java計算器程序源代碼_第1頁
java計算器程序源代碼_第2頁
java計算器程序源代碼_第3頁
java計算器程序源代碼_第4頁
java計算器程序源代碼_第5頁
已閱讀5頁,還剩15頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認(rèn)領(lǐng)

文檔簡介

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(;          /顯示位置設(shè)置 ( 3.Li Leis shoes are all under the chair.          Dimension labelSize=welpic.getPreferredS

4、ize(;( 4.The windows of the bedroom are brown.         /鼠標(biāo)事件點擊退出         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、;   /*為了解決這個問題,根據(jù)短文內(nèi)容選擇正確答案:設(shè)計者賦予我們安全地把Runnable對象加入UI事件隊列的能力。在本例中,. 我們用可運行對象closerRunner A.twelve B.eleven SwingUtilities.invokeAndWait(wingUtilities.invokeAndWait( D.twevle ten      UI操作,并執(zhí)行傳遞給該方法的可運行對象closerRunner的A.bus B.carC.bike D.taxi迎屏幕的關(guān)閉操作,應(yīng)用擔(dān)負起了顯示和關(guān)閉歡迎屏幕之

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是非線程安全的,除非代碼在事件分派線程上執(zhí)行,否則它就不應(yīng)該影響任何UI組件的狀1 態(tài)。所謂事件分派線程,就是Swing中負責(zé)繪圖和事件處理的線程。*/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、           )用所給詞的適當(dāng)形式填空 (                分)                 ;      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("粘貼"內(nèi)容提要:    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='÷出現(xiàn)了對非數(shù)字計算問題!"                               

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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論