氟塑料離心泵www.buybeng.com

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

          java上機 第五周 任務5 封裝一個矩陣類

          1. /*  
          2. * 程序頭部注釋開始    
          3. * 程序的版權和版本聲明部分    
          4. * Copyright (c) 2011, 煙臺大學計算機學院學生    
          5. * All rights reserved.    
          6. * 文件名稱:GUI(練習-列出指定目錄內容 有對話框Dialog)                            
          7. * 作    者:薛廣晨                                
          8. * 完成日期:2011  年 09 月  20  日    
          9. * 版 本號:x1.0             
          10.     
          11. * 對任務及求解方法的描述部分    
          12. * 輸入描述:   
          13. * 問題描述:     
          14. * 程序輸出:    
          15. * 程序頭部的注釋結束  
          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("轉到");  
          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. }  


          運行結果:


          個人網站  www.software8.co

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


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


          網站導航:
           
          <2012年9月>
          2627282930311
          2345678
          9101112131415
          16171819202122
          23242526272829
          30123456

          導航

          統計

          常用鏈接

          留言簿

          隨筆檔案

          文章檔案

          技術網站

          行業網站

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          站長網 氟塑料離心泵 注塑機 液晶廣告機
          主站蜘蛛池模板: 西华县| 焉耆| 息烽县| 鄱阳县| 阳高县| 安福县| 麻城市| 藁城市| 伊春市| 新宁县| 白朗县| 古丈县| 古交市| 巴中市| 威海市| 齐河县| 孝义市| 海原县| 德钦县| 东海县| 新乡市| 浦城县| 祁东县| 保亭| 建湖县| 溧阳市| 益阳市| 广宁县| 图们市| 枞阳县| 疏附县| 宁夏| 海淀区| 罗平县| 漾濞| 府谷县| 天等县| 新巴尔虎左旗| 招远市| 唐海县| 正定县|