氟塑料離心泵www.buybeng.com

          jquery教程http://www.software8.co/wzjs/jquery/

          java上機(jī) 第五周 任務(wù)5 封裝一個矩陣類

          1. /*  
          2. * 程序頭部注釋開始    
          3. * 程序的版權(quán)和版本聲明部分    
          4. * Copyright (c) 2011, 煙臺大學(xué)計(jì)算機(jī)學(xué)院學(xué)生    
          5. * All rights reserved.    
          6. * 文件名稱:GUI(練習(xí)-列出指定目錄內(nèi)容 有對話框Dialog)                            
          7. * 作    者:薛廣晨                                
          8. * 完成日期:2011  年 09 月  20  日    
          9. * 版 本號:x1.0             
          10.     
          11. * 對任務(wù)及求解方法的描述部分    
          12. * 輸入描述:   
          13. * 問題描述:     
          14. * 程序輸出:    
          15. * 程序頭部的注釋結(jié)束  
          16. */  
          17.   
          18. package xue;  
          19. import java.awt.*;  
          20. import java.awt.event.*;  
          21. import java.io.File;  
          22.   
          23. public class MyDiaglog {  
          24.   
          25.     /** 
          26.      * @param args 
          27.      */  
          28.     private Frame f;  
          29.     private TextField tf;  
          30.     private Button but;  
          31.     private TextArea ta;  
          32.       
          33.     private Dialog d;  
          34.     private Label lab;  
          35.     private Button okBut;  
          36.       
          37.     MyDiaglog()  
          38.     {  
          39.         init();  
          40.     }  
          41.     public void init()  
          42.     {  
          43.         f = new Frame("my window");  
          44.         f.setBounds(300100600500);  
          45.         f.setLayout(new FlowLayout());  
          46.           
          47.         tf = new TextField(60);  
          48.           
          49.         but = new Button("轉(zhuǎn)到");  
          50.           
          51.         ta = new TextArea(2570);  
          52.           
          53.         d = new Dialog(f, "提示信息——self", true);  
          54.         d.setBounds(400200240,150);  
          55.         d.setLayout(new FlowLayout());  
          56.         lab = new Label();  
          57.         okBut = new Button("確定");  
          58.           
          59.         d.add(lab);  
          60.         d.add(okBut);  
          61.           
          62.         f.add(tf);  
          63.         f.add(but);  
          64.         f.add(ta);  
          65.           
          66.         myEvent();  
          67.         f.setVisible(true);  
          68.     }  
          69.     private void myEvent() {  
          70.         // TODO Auto-generated method stub  
          71.         d.addWindowListener(new WindowAdapter()  
          72.         {  
          73.             public void windowClosing(WindowEvent e)  
          74.             {  
          75.                 d.setVisible(false);  
          76.             }  
          77.         });  
          78.           
          79.         okBut.addActionListener(new ActionListener()  
          80.         {  
          81.             public void actionPerformed(ActionEvent e)  
          82.             {  
          83.                 d.setVisible(false);  
          84.             }  
          85.         });  
          86.         tf.addKeyListener(new KeyAdapter()  
          87.         {  
          88.             public void keyPressed(KeyEvent e)  
          89.             {  
          90.                 if(e.getKeyCode() == KeyEvent.VK_ENTER)  
          91.                 {  
          92.                     showDir();  
          93.                 }  
          94.             }     
          95.         });  
          96.           
          97.         but.addActionListener(new ActionListener()  
          98.         {  
          99.             public void actionPerformed(ActionEvent e)  
          100.             {  
          101.                 showDir();  
          102.             }  
          103.         });  
          104.         f.addWindowListener(new WindowAdapter()  
          105.         {  
          106.             public void windowClosing(WindowEvent e)  
          107.             {  
          108.                 System.exit(0);  
          109.             }  
          110.         });  
          111.           
          112.     }  
          113.       
          114.     private void showDir()   
          115.     {  
          116.         // TODO Auto-generated method stub  
          117.         String dirPath = tf.getText();  
          118.           
          119.         File dir = new File(dirPath);  
          120.         if(dir.exists() && dir.isDirectory())  
          121.         {  
          122.             ta.setText("");  
          123.             String[] names = dir.list();  
          124.             for(String name : names)  
          125.             {  
          126.                 ta.append(name + "\r\n");  
          127.             }  
          128.         }  
          129.         else  
          130.         {  
          131.             String info = "您輸入的信息:"+dirPath+"是錯誤的。請重輸";  
          132.             lab.setText(info);  
          133.             d.setVisible(true);  
          134.         }  
          135.           
          136.     }  
          137.       
          138.     public static void main(String[] args) {  
          139.         // TODO Auto-generated method stub  
          140.         new MyDiaglog();  
          141.   
          142.     }  
          143.   
          144. }  


          運(yùn)行結(jié)果:


          個人網(wǎng)站  www.software8.co

          posted on 2012-09-28 17:30 你爸是李剛 閱讀(146) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          <2012年9月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          30123456

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿

          隨筆檔案

          文章檔案

          技術(shù)網(wǎng)站

          行業(yè)網(wǎng)站

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          站長網(wǎng) 氟塑料離心泵 注塑機(jī) 液晶廣告機(jī)
          主站蜘蛛池模板: 大荔县| 奎屯市| 黄梅县| 青海省| 光山县| 扶余县| 富民县| 杭锦后旗| 泌阳县| 西乌| 英超| 英吉沙县| 辽宁省| 东辽县| 嘉兴市| 建宁县| 崇阳县| 临沂市| 洪泽县| 广灵县| 高陵县| 开平市| 郯城县| 湖州市| 彭水| 凤阳县| 聂拉木县| 扶风县| 东港市| 名山县| 永清县| 潢川县| 高雄市| 民县| 镇雄县| 克什克腾旗| 缙云县| 嘉禾县| 义马市| 吉安市| 安达市|