java blog

          java boy

          常用鏈接

          統計

          最新評論

          2009年12月10日 #

          記錄庫操作工具類


          import javax.microedition.rms.InvalidRecordIDException;
          import javax.microedition.rms.RecordStore;
          import javax.microedition.rms.RecordStoreException;
          import javax.microedition.rms.RecordStoreFullException;
          import javax.microedition.rms.RecordStoreNotFoundException;
          import javax.microedition.rms.RecordStoreNotOpenException;


          public class RecordStoreUtil {
          public RecordStore openARecondStore(String rsname){
              RecordStore rs=null;
              if(rsname.length()>32) return null;
              try{
                   rs=RecordStore.openRecordStore(rsname,true);
              }catch(RecordStoreFullException notFoundException){

              }catch(RecordStoreNotFoundException notFoundException){

              }catch(RecordStoreException notFoundException){

              }finally{
                  return rs;
              }
          }
          public RecordStore openARecordStoreExisted(String rsname){
              RecordStore rs=null;
              if(rsname.length()>32)return null;
             try{
                   rs=RecordStore.openRecordStore(rsname,false);
              }catch(RecordStoreFullException notFoundException){

              }catch(RecordStoreNotFoundException notFoundException){

              }catch(RecordStoreException notFoundException){

              }finally{
                  return rs;
              }
          }
           //刪除
          public static boolean delRecordStore(String rsname){
              //
              if(rsname.length()>32)return false;
              //

             try{
                 RecordStore.deleteRecordStore(rsname);

             }catch(Exception e){
                 return false;
             }
              return true;
          }
          //添加
          public static int writeString(RecordStore rs,String myString){
              byte[] b=myString.getBytes();
              int id=-1;
              try{
                  id=rs.addRecord(b, 0, b.length);

              }catch(Exception e){
                  //
             
          }
              return id;
          }

          //獲取
          public static String getString(RecordStore rs,int id){
                  try {
                      byte[] b = rs.getRecord(id);
                      return (new String(b));
                  } catch (RecordStoreNotOpenException ex) {
                      ex.printStackTrace();
                  } catch (InvalidRecordIDException ex) {
                      ex.printStackTrace();
                  } catch (RecordStoreException ex) {
                      ex.printStackTrace();
                  }
                  return null;

          }
          //修改
          public static void setString(RecordStore rs,int id,String newString){
              byte[] b=newString.getBytes();
                  try {
                      rs.setRecord(id, b, 0, b.length);
                  } catch (Exception ex) {

                  }
          }
          //添加證書數據記錄
          public static int writeInt(RecordStore rs,int myInt){
              int id=-1;
              String myString=(new Integer(myInt)).toString();
              id=writeString(rs,myString);
              return id;
          }
          //獲取
          public static int getInt(RecordStore rs,int id){
              int result=Integer.MAX_VALUE;
              String s=getString(rs,id);
              try{
              result=Integer.parseInt(s);
              }catch(Exception e){

              }
              return result;
          }
          //修改
          public static void setInt(RecordStore rs,int newInt){
              String myString=(new Integer(newInt)).toString();
          }

           

           

           

           


          }

          posted @ 2009-12-10 19:09 javaz 閱讀(284) | 評論 (0)編輯 收藏

          2009年12月7日 #

          XP.CMD命令大全

          XP.CMD命令大全


          有關某個命令的詳細信息,請鍵入 HELP 命令名
          ASSOC 顯示或修改文件擴展名關聯。
          AT 計劃在計算機上運行的命令和程序。
          ATTRIB 顯示或更改文件屬性。
          BREAK 設置或清除擴展式 CTRL+C 檢查。
          CACLS 顯示或修改文件的訪問控制列表(ACLs)。
          CALL 從另一個批處理程序調用這一個。
          CD 顯示當前目錄的名稱或將其更改。
          CHCP 顯示或設置活動代碼頁數。
          CHDIR 顯示當前目錄的名稱或將其更改。
          CHKDSK 檢查磁盤并顯示狀態報告。
          CHKNTFS 顯示或修改啟動時間磁盤檢查。
          CLS 清除屏幕。
          CMD 打開另一個 Windows 命令解釋程序窗口。
          COLOR 設置默認控制臺前景和背景顏色。
          COMP 比較兩個或兩套文件的內容。
          COMPACT 顯示或更改 NTFS 分區上文件的壓縮。
          CONVERT 將 FAT 卷轉換成 NTFS。您不能轉換
          當前驅動器。
          COPY 將至少一個文件復制到另一個位置。
          DATE 顯示或設置日期。
          DEL 刪除至少一個文件。
          DIR 顯示一個目錄中的文件和子目錄。
          DISKCOMP 比較兩個軟盤的內容。
          DISKCOPY 將一個軟盤的內容復制到另一個軟盤。
          DOSKEY 編輯命令行、調用 Windows 命令并創建宏。
          ECHO 顯示消息,或將命令回顯打開或關上。
          ENDLOCAL 結束批文件中環境更改的本地化。
          ERASE 刪除至少一個文件。
          EXIT 退出 CMD.EXE 程序(命令解釋程序)。
          FC 比較兩個或兩套文件,并顯示
          不同處。
          FIND 在文件中搜索文字字符串。
          FINDSTR 在文件中搜索字符串。
          FOR 為一套文件中的每個文件運行一個指定的命令。
          FORMAT 格式化磁盤,以便跟 Windows 使用。
          FTYPE 顯示或修改用于文件擴展名關聯的文件類型。
          GOTO 將 Windows 命令解釋程序指向批處理程序
          中某個標明的行。
          GRAFTABL 啟用 Windows 來以圖像模式顯示
          擴展字符集。
          HELP 提供 Windows 命令的幫助信息。
          IF 執行批處理程序中的條件性處理。
          LABEL 創建、更改或刪除磁盤的卷標。
          MD 創建目錄。
          MKDIR 創建目錄。
          MODE 配置系統設備。
          MORE 一次顯示一個結果屏幕。
          MOVE 將文件從一個目錄移到另一個目錄。
          PATH 顯示或設置可執行文件的搜索路徑。
          PAUSE 暫停批文件的處理并顯示消息。
          POPD 還原 PUSHD 保存的當前目錄的上一個值。
          PRINT 打印文本文件。
          PROMPT 更改 Windows 命令提示符。
          PUSHD 保存當前目錄,然后對其進行更改。
          RD 刪除目錄。
          RECOVER 從有問題的磁盤恢復可讀信息。
          REM 記錄批文件或 CONFIG.SYS 中的注釋。
          REN 重命名文件。
          RENAME 重命名文件。
          REPLACE 替換文件。
          RMDIR 刪除目錄。
          SET 顯示、設置或刪除 Windows 環境變量。
          SETLOCAL 開始批文件中環境更改的本地化。
          SHIFT 更換批文件中可替換參數的位置。
          SORT 對輸入進行分類。
          START 啟動另一個窗口來運行指定的程序或命令。
          SUBST 將路徑跟一個驅動器號關聯。
          TIME 顯示或設置系統時間。
          TITLE 設置 CMD.EXE 會話的窗口標題。
          TREE 以圖形模式顯示驅動器或路徑的目錄結構。
          TYPE 顯示文本文件的內容。
          VER 顯示 Windows 版本。
          VERIFY 告訴 Windows 是否驗證文件是否已正確
          寫入磁盤。
          VOL 顯示磁盤卷標和序列號。
          XCOPY 復制文件和目錄樹。


          appwiz.cpl------------添加刪除程序

          control userpasswords2--------用戶帳戶設置

          cleanmgr-------垃圾整理

          CMD--------------命令提示符可以當作是 Windows 的一個附件,Ping,Convert 這些不能在圖形環境下 使用的功能要借助它來完成。

          cmd------jview察看Java虛擬機版本。


          command.com------調用的則是系統內置的 NTVDM,一個 DOS虛擬機。它完全是一個類似 Virtual PC 的 虛擬環境,和系統本身聯系不大。當我們在命令提示符下運行 DOS 程序時,實際上也 是自動轉移到 NTVDM虛擬機下,和 CMD 本身沒什么關系。


          calc-----------啟動計算器

          chkdsk.exe-----Chkdsk磁盤檢查

          compmgmt.msc---計算機管理

          conf-----------啟動 netmeeting

          control userpasswords2-----User Account 權限設置

          devmgmt.msc--- 設備管理器

          diskmgmt.msc---磁盤管理實用程序

          dfrg.msc-------磁盤碎片整理程序

          drwtsn32------ 系統醫生

          dvdplay--------啟動Media Player

          dxdiag-----------DirectX Diagnostic Tool

          gpedit.msc-------組策略編輯器

          gpupdate /target:computer /force 強制刷新組策略

          eventvwr.exe-----事件查看器

          explorer-------打開資源管理器

          logoff---------注銷命令

          lusrmgr.msc----本機用戶和組

          msinfo32---------系統信息

          msconfig---------系統配置實用程序

          net start (servicename)----啟動該服務

          net stop (servicename)-----停止該服務

          notepad--------打開記事本

          nusrmgr.cpl-------同control userpasswords,打開用戶帳戶控制面板

          Nslookup-------IP地址偵測器

          oobe/msoobe /a----檢查XP是否激活

          perfmon.msc----計算機性能監測程序

          progman--------程序管理器

          regedit----------注冊表編輯器

          regedt32-------注冊表編輯器

          regsvr32 /u *.dll----停止dll文件運行

          route print------查看路由表

          rononce -p ----15秒關機

          rsop.msc-------組策略結果集

          rundll32.exe rundll32.exe %Systemroot%System32shimgvw.dll,ImageView_Fullscreen----啟動一個空白的Windows 圖片和傳真查看器

          secpol.msc--------本地安全策略

          services.msc---本地服務設置

          sfc /scannow-----啟動系統文件檢查器

          sndrec32-------錄音機

          taskmgr-----任務管理器(適用于2000/xp/2003)

          tsshutdn-------60秒倒計時關機命令

          winchat--------XP自帶局域網聊天

          winmsd---------系統信息

          winver-----顯示About Windows 窗口

          wupdmgr-----------Windows Update

          posted @ 2009-12-07 16:13 javaz 閱讀(249) | 評論 (0)編輯 收藏

          MySQL語句大全

          一、連接mysql。
          格式: mysql -h主機地址 -u用戶名 -p用戶密碼
          1、連接到本機上的MYSQL。
          首先打開DOS窗口,然后進入目錄mysql\bin,再鍵入命令mysql -u root -p,回車后提示你輸密碼.注意用戶名前可以有空格也可以沒有空格,但是密碼前必須沒有空格,否則讓你重新輸入密碼.
          如果剛安裝好MYSQL,超級用戶root是沒有密碼的,故直接回車即可進入到MYSQL中了,MYSQL的提示符是: mysql>
          2、連接到遠程主機上的MYSQL。假設遠程主機的IP為:110.110.110.110,用戶名為root,密碼為abcd123。則鍵入以下命令:
             mysql -h110.110.110.110 -u root -p 123;(注:u與root之間可以不用加空格,其它也一樣)
          3、退出MYSQL命令: exit (回車)

          二、修改密碼。
          格式:mysqladmin -u用戶名 -p舊密碼 password 新密碼
          1、給root加個密碼ab12。首先在DOS下進入目錄mysql\bin,然后鍵入以下命令
             mysqladmin -u root -password ab12
             注:因為開始時root沒有密碼,所以-p舊密碼一項就可以省略了。
          2、再將root的密碼改為djg345。
             mysqladmin -u root -p ab12 password djg345
          三、增加新用戶。
          (注意:和上面不同,下面的因為是MYSQL環境中的命令,所以后面都帶一個分號作為命令結束符)
          格式:grant select on 數據庫.* to 用戶名@登錄主機 identified by "密碼"
          1、增加一個用戶test1密碼為abc,讓他可以在任何主機上登錄,并對所有數據庫有查詢、插入、修改、刪除的權限。首先用root用戶連入MYSQL,然后鍵入以下命令:
             grant select,insert,update,delete on *.* to test1@"%" Identified by "abc";
             但增加的用戶是十分危險的,你想如某個人知道test1的密碼,那么他就可以在internet上的任何一臺電腦上登錄你的mysql數據庫并對你的數據可以為所欲為了,解決辦法見2。
          2、增加一個用戶test2密碼為abc,讓他只可以在localhost上登錄,并可以對數據庫mydb進行查詢、插入、修改、刪除的操作(localhost指本地主機,即MYSQL數據庫所在的那臺主機),
             這樣用戶即使用知道test2的密碼,他也無法從internet上直接訪問數據庫,只能通過MYSQL主機上的web頁來訪問了。
             grant select,insert,update,delete on mydb.* to test2@localhost identified by "abc";
             如果你不想test2有密碼,可以再打一個命令將密碼消掉。
             grant select,insert,update,delete on mydb.* to test2@localhost identified by "";


          四、顯示命令
          mysql> select version();        查看MySQL的版本號
          mysql> select current_date();        查看MySQL的當前日期
          mysql> select version(),current_date(); 同時查看MySQL的版本號和當前日期
          mysql> show databases;            顯示當前存在的數據庫
          mysql> USE mysql            選擇使用數據庫(USE和QUIT命令不需要分號結束)
          Database changed
          mysql> select database();        顯示當前選擇的數據庫
          mysql> show tables;            顯示當前數據庫中存在的表
          mysql> select * from db;        顯示表(db)的內容   
          mysql> describe mytable;        顯示表的結構

          1、顯示當前數據庫服務器中的數據庫列表:
          mysql> SHOW DATABASES;
          注意:mysql庫里面有MYSQL的系統信息,我們改密碼和新增用戶,實際上就是用這個庫進行操作。
          2、顯示數據庫中的數據表:
          mysql> USE 庫名;
          mysql> SHOW TABLES;
          3、顯示數據表的結構:
          mysql> DESCRIBE 表名;
          4、建立數據庫:
          mysql> CREATE DATABASE 庫名;
          5、建立數據表:
          mysql> USE 庫名;
          mysql> CREATE TABLE 表名 (字段名 VARCHAR(20), 字段名 CHAR(1));
          6、刪除數據庫:
          mysql> DROP DATABASE 庫名;
          7、刪除數據表:
          mysql> DROP TABLE 表名;
          8、將表中記錄清空:
          mysql> DELETE FROM 表名;
          9、顯示表中的記錄:
          mysql> SELECT * FROM 表名;
          10、往表中插入記錄:
          mysql> INSERT INTO 表名 VALUES ("hyq","M");
          11、更新表中數據:
          mysql-> UPDATE 表名 SET 字段名1='a',字段名2='b' WHERE 字段名3='c';
          12、用文本方式將數據裝入數據表中:
          mysql> LOAD DATA LOCAL INFILE "D:/mysql.txt" INTO TABLE 表名;
          13、導入.sql文件命令:
          mysql> USE 數據庫名;
          mysql> SOURCE d:/mysql.sql;
          14、命令行修改root密碼:
          mysql> UPDATE mysql.user SET password=PASSWORD('新密碼') WHERE User='root';
          mysql> FLUSH PRIVILEGES;
          注意用此種方法修改密碼時別忘了 password=password('新密碼') 如果直接用 password='新密碼',下次登錄時會出現問題以至于登錄不進去,因為此密碼沒用經過password()函數處理,這樣寫入到user表中的密碼系統不能識別就會顯示用戶名和密碼錯誤的信息。
          如果在修改密碼的過程中出現問題以至于沒有一個用戶可以進入mysql則可以用以下的方法重新修改用戶名和密碼:
          bin>mysqld --skip-grant-tables;然后再在 另外一個bin>mysql 便可直接進入mysql ,進入后便修改相關數據。
          15、顯示use的數據庫名:
          mysql> SELECT DATABASE();
          16、顯示當前的user:
          mysql> SELECT USER();
          五、一個建庫和建表以及插入數據的實例
          drop database if exists school; //如果存在SCHOOL則刪除
          create database school; //建立庫SCHOOL
          use school; //打開庫SCHOOL
          create table teacher //建立表TEACHER
          (
          id int(3) auto_increment not null primary key,
          name char(10) not null,
          address varchar(50) default '深圳',
          year date
          ); //建表結束
          //以下為插入字段
          insert into teacher values('','allen','大連一中','1976-10-10');
          insert into teacher values('','jack','大連二中','1975-12-23');
          如果你在mysql提示符鍵入上面的命令也可以,但不方便調試。
          (1)你可以將以上命令原樣寫入一個文本文件中,假設為school.sql,然后復制到c:\\下,并在DOS狀態進入目錄,然后鍵入以下命令:
               mysql -uroot -p密碼 < c:\\school.sql
               如果成功,空出一行無任何顯示;如有錯誤,會有提示。(以上命令已經調試,你只要將//的注釋去掉即可使用)。
          (2)或者進入命令行后使用 mysql> source c:\\school.sql; 也可以將school.sql文件導入數據庫中。

          六、將文本數據轉到數據庫中
          1、文本數據應符合的格式:字段數據之間用tab鍵隔開,null值用來代替.例:
             3 rose 大連二中 1976-10-10
             4 mike 大連一中 1975-12-23
             假設你把這兩組數據存為school.txt文件,放在c盤根目錄下。
          2、數據傳入命令 load data local infile "c:\\school.txt" into table 表名;
             注意:你最好將文件復制到目錄下,并且要先用use命令打表所在的庫。

          七、備份數據庫:(命令在DOS的目錄下執行)
          1.導出整個數據庫
          導出文件默認是存在mysql\bin目錄下
          mysqldump -u 用戶名 -p 數據庫名 > 導出的文件名
          mysqldump -u user_name -p123456 database_name > outfile_name.sql
          2.導出一個表
          mysqldump -u 用戶名 -p 數據庫名 表名> 導出的文件名
          mysqldump -u user_name -p database_name table_name > outfile_name.sql
          3.導出一個數據庫結構
          mysqldump -u user_name -p -d --add-drop-table database_name > outfile_name.sql
          -d 沒有數據 --add-drop-table 在每個create語句之前增加一個drop table
          4.帶語言參數導出
          mysqldump -uroot -p --default-character-set=latin1 --set-charset=gbk --skip-opt database_name > outfile_name.sql

          posted @ 2009-12-07 16:11 javaz 閱讀(2680) | 評論 (0)編輯 收藏

          2009年12月3日 #

          swt_jface(2) 幾種常用布局

          // RowLayoutTest .java
          import org.eclipse.swt.SWT;
          import org.eclipse.swt.layout.FillLayout;
          import org.eclipse.swt.layout.RowData;
          import org.eclipse.swt.layout.RowLayout;
          import org.eclipse.swt.widgets.Button;
          import org.eclipse.swt.widgets.Display;
          import org.eclipse.swt.widgets.Shell;

          public class RowLayoutTest {

           /**
            * @param args
            */
           public static void main(String[] args) {
            Display display=new Display();
            Shell shell=new Shell();
            shell.setText("標題");
            shell.setSize(400,300);
            
            
          //RowLayout布局就是是組件按行排列
            //shell.setLayout(new RowLayout());
            
            //組件
            new Button(shell,SWT.NONE).setText("kkk");
            new Button(shell, SWT.NONE).setText("確定");
            new Button(shell,SWT.NONE).setText("kk1");
            new Button(shell, SWT.NONE).setText("確1");
            new Button(shell,SWT.NONE).setText("kk2");
            new Button(shell, SWT.NONE).setText("確2");
            new Button(shell,SWT.NONE).setText("kkk");
            new Button(shell, SWT.NONE).setText("確定");
            new Button(shell,SWT.NONE).setText("kk1");
            new Button(shell, SWT.NONE).setText("確1");
            new Button(shell,SWT.NONE).setText("kk2");
            new Button(shell, SWT.NONE).setText("確2");
            new Button(shell,SWT.NONE).setText("kkk");
            new Button(shell, SWT.NONE).setText("確定");
            new Button(shell,SWT.NONE).setText("kk1");
            new Button(shell, SWT.NONE).setText("確1");
            new Button(shell,SWT.NONE).setText("kk2");
            new Button(shell, SWT.NONE).setText("確2");
            
            

            RowLayout layout = new RowLayout( /*SWT.VERTICAL垂直排列*/ );
            layout.marginWidth = 20;
            layout.marginHeight = 10;
            layout.spacing = 15;
            //垂直排列
            //layout.type = SWT.VERTICAL;

             //設置布局管理器上的組件大小相同
            //layout.pack = false;
            
            // 設置布局管理器上的組件根據容器空間可以拉伸
            layout.justify = true;
            
              //不自動換行
             // layout.wrap = false;

             
            new Button(shell, SWT.NONE).setText("確定");
            
            Button b = new Button(shell, SWT.NONE);
            b.setText("取消");
            // 使用RowData布局數據類來控制按鈕,使按鈕改為50像素寬,30像素長
            RowData rowData = new RowData(50, 30);  
            // 把組件隱藏不占位,相當于組件不存在
            //rowData.exclude = true;
            rowData.width = 100;
            //把組件隱藏,但位置還占著
            //b.setVisible(false);
            b.setLayoutData(rowData);
            
            new Button(shell, SWT.NONE).setText("幫助");
            
            shell.setLayout(layout);
            
            
            shell.open();
            while(!shell.isDisposed()){
             if(!display.readAndDispatch()){
              display.sleep();
             }
            }
            display.dispose();
           }

          }


          //GridLayoutTest
          import org.eclipse.swt.SWT;
          import org.eclipse.swt.layout.GridData;
          import org.eclipse.swt.layout.GridLayout;
          import org.eclipse.swt.widgets.Button;
          import org.eclipse.swt.widgets.Display;
          import org.eclipse.swt.widgets.Shell;

          public class GridLayoutTest {

           /**
            * @param args
            */
           /**
            * @param args
            */
           public static void main(String[] args) {
            Display display = new Display();
            Shell shell = new Shell();
            shell.setText("標題");
            shell.setSize(400, 300);

            //GridLayout為網格布局
            //4代表把這個布局分成幾列
            //false代表是否等距分隔空間
            shell.setLayout(new GridLayout(4, true));

            // 組建
            new Button(shell, SWT.NONE).setText("kkk");
            new Button(shell, SWT.NONE).setText("確定");
            new Button(shell, SWT.NONE).setText("kk1");
             new Button(shell, SWT.NONE).setText("確1");
             new Button(shell,SWT.NONE).setText("kk2");
             new Button(shell, SWT.NONE).setText("確2");
             new Button(shell, SWT.NONE).setText("kkk");
             new Button(shell, SWT.NONE).setText("確定");
             new Button(shell, SWT.NONE).setText("kk1");
             new Button(shell, SWT.NONE).setText("確1");
             new Button(shell,SWT.NONE).setText("kk2");
             new Button(shell, SWT.NONE).setText("確2");
            // 定義一個GridData對象,讓幫助按鈕占用n列的空間
             Button helpButton = new Button(shell, SWT.NONE);
             
             //GridData.FILL_VERTICAL是按鈕垂直放置
             GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL/*這個是水平對齊式填充*//* GridData.FILL_HORIZONTAL 這個是水平搶占式填充*//* GridData.FILL_VERTICAL*/);
             gridData.horizontalSpan = 3;//該句使按鈕占用兩列空間
             //gridData.grabExcessHorizontalSpace=true;
             
             //gridData.verticalSpan = 2;
             //gridData.grabExcessVerticalSpace=true;
             helpButton.setLayoutData(gridData);
             
             helpButton.setText("幫助");

              new Button(shell, SWT.NONE).setText("kk1");
              new Button(shell, SWT.NONE).setText("確1");
              new Button(shell,SWT.NONE).setText("kk2");
              new Button(shell, SWT.NONE).setText("確2");
            
            
            
            shell.open();
            while (!shell.isDisposed()) {
             if (!display.readAndDispatch()) {
              display.sleep();
             }
            }
            display.dispose();

           }

          }

          //FillLayoutTest

          import org.eclipse.swt.SWT;
          import org.eclipse.swt.layout.FillLayout;
          import org.eclipse.swt.widgets.Button;
          import org.eclipse.swt.widgets.Display;
          import org.eclipse.swt.widgets.Shell;

          public class FillLayoutTest {

           
           public static void main(String[] args) {
            Display display=new Display();
            Shell shell=new Shell();
            shell.setText("標題");
            shell.setSize(400,300);
            
            //布局FillLayout就是使組建占滿整個容器 默認為橫著排  SWT.VERTICAL是組建垂直排
          //  shell.setLayout(new FillLayout(SWT.VERTICAL));
            shell.setLayout(new FillLayout());
            
            //組建
            new Button(shell,SWT.NONE).setText("kkk");
            new Button(shell, SWT.NONE).setText("確定");
            new Button(shell,SWT.NONE).setText("kk1");
          //  new Button(shell, SWT.NONE).setText("確1");
          //  new Button(shell,SWT.NONE).setText("kk2");
          //  new Button(shell, SWT.NONE).setText("確2");
            shell.open();
            while(!shell.isDisposed()){
             if(!display.readAndDispatch()){
              display.sleep();
             }
            }
            display.dispose();
            
            
            
           }

          }

          posted @ 2009-12-03 08:17 javaz 閱讀(984) | 評論 (0)編輯 收藏

          2009年12月2日 #

          如何在MyEclipse中導入Struts包和數據庫包?

           

          右鍵單擊web工程名,在出現的右鍵菜單欄中會有一行“MyEclipse”,選擇這個,在出現的欄中再選擇“Add Struts Capabilities”,出現對話框,點擊OK了。





          posted @ 2009-12-02 14:12 javaz 閱讀(669) | 評論 (0)編輯 收藏

          2009年12月1日 #

          靜夜思

           

          import javax.microedition.lcdui.*;
          import javax.microedition.midlet.*;


          public class GraphicsTest extends MIDlet{
            private Display display;

              public GraphicsTest() {
                  display=Display.getDisplay(this);

              }

              protected void destroyApp(boolean unconditional)  {


              }

              protected void pauseApp() {

              }

              protected void startApp(){
               MyCanvas mc=new MyCanvas();
               display.setCurrent(mc);
              }


          }
          class MyCanvas extends Canvas {

              public void paint(Graphics g){
               int width=getWidth();
               int height=getHeight();
          String a[]={"靜夜思","李白","床前明月光","疑是地上霜","舉頭望明月","低頭思故鄉"};
               g.setColor(0);
               g.fillRect(0, 0, width, height);

             
               g.setColor(0Xffff00);
               Font font=g.getFont();
               font=Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_UNDERLINED,Font.SIZE_LARGE);
               g.setFont(font);
               for(int i=0;i<a.length;i++){
                   g.drawString(a[i], 0, i*20,Graphics.LEFT|Graphics.BASELINE );
               }
             
              }

          }

           //--------------------------------------------------------------------------------------------
          利用移動原點坐標動起來之后的靜夜思

          import javax.microedition.lcdui.*;
          import javax.microedition.midlet.*;


          public class GraphicsTest extends MIDlet{
            private Display display;

              public GraphicsTest() {
                  display=Display.getDisplay(this);

              }

              protected void destroyApp(boolean unconditional)  {


              }

              protected void pauseApp() {

              }

              protected void startApp(){
               MyCanvas mc=new MyCanvas();
               display.setCurrent(mc);
              }


          }
          class MyCanvas extends Canvas {
          int aa=300;

          MyCanvas(){
          Walk w = new Walk();
            w.start();
          }
              public void paint(Graphics g){
               int width=getWidth();
               int height=getHeight();
          String a[]={"靜夜思","李白","床前明月光","疑是地上霜","舉頭望明月","低頭思故鄉"};
               g.setColor(0);
               g.fillRect(0, 0, width, height);


               g.setColor(0Xffff00);
               g.translate(80,aa);
               Font font=g.getFont();

               font=Font.getFont(Font.FACE_PROPORTIONAL,Font.FACE_SYSTEM,Font.SIZE_LARGE);
               g.setFont(font);
               for(int i=0;i<a.length;i++){
                   g.drawString(a[i], 0, i*20,20);
               }

              }


          class Walk extends Thread{

            public void run(){
             while(aa>80){
              aa--;
              repaint();
              try{
               sleep(50);
              }catch(Exception ee){}
             }
            }
           }

          }

          posted @ 2009-12-01 20:25 javaz 閱讀(317) | 評論 (0)編輯 收藏

          javaME 線與弧形

           

          import javax.microedition.lcdui.*;
          import javax.microedition.midlet.*;


          public class GraphicsTest extends MIDlet{
            private Display display;

              public GraphicsTest() {
                  display=Display.getDisplay(this);

              }
           
              protected void destroyApp(boolean unconditional)  {
               
                 
              }

              protected void pauseApp() {
                 
              }

              protected void startApp(){
               MyCanvas mc=new MyCanvas();
               display.setCurrent(mc);
              }


          }
          class MyCanvas extends Canvas {

              public void paint(Graphics g){
               int width=getWidth();
               int height=getHeight();
              
               g.setColor(0);
               g.fillRect(0, 0, width, height);
              
               int a=width/5;
               int b=height/5;
               g.setColor(0Xffff00);
               for(int i=1;i<=4;i++){
               g.drawLine(a,0 ,a,height);
               g.drawLine( 0,b,  width,b);
               a=a+width/5;
               b=b+height/5;
              
               } g.drawArc(0, 0, width, height, 0, 360);
              }

          }

           

          posted @ 2009-12-01 20:01 javaz 閱讀(168) | 評論 (0)編輯 收藏

          MyEclipse卡機問題的解決

          在用[MyEclipse] 寫代碼很容易卡死機,尤其是在對JSP文件的<%%>之間寫代碼的時候,只要一彈出智能提示就立刻卡死,程序失去響應,我以為是MyEclipse版本的問題,結果換了6.0版-》6.5版-》7.0版全都一樣,難道是我機子的問題?可是還原系統后用還是一樣的結果。


          在網上找了很久才知道,是MyEclipse在智能提示的時候自動訪問網絡上sun公司的最新API文檔,只要關閉掉網絡連接就可以了。我試了試斷開網絡然后在用MyEclipse寫代碼,結果還真的搞定了。可是,我總不能因為個這就不上網了吧,終于,找到了兩全其美的解決方法。

          在自己創建的工程名上右鍵,選擇Properties》在打開的窗口中點擊Java Build Path》單擊Libraries選項卡,找到

          JRE System Libraries->charsets.jar->Javadoc location

          選中Javadoc location,再選擇右邊的Remove,更改成Javadoc location: (None),點擊OK。
          接下來在寫代碼的時候就不會再卡死了。

          MyEclipse 6.5編寫jsp代碼時聯想輸入無響應解決方法   
          很頭疼的一個問題,在jsp頁面輸入“.”之后,MyEclipse往往會出現無響應,要等上好幾分鐘才能恢復正常,找了很多方法,下面這個方法是最有效的,其實很簡單:


          Window-->java-->Installed JREs-->選中你的版本-->Edit-->選中jar包-->Javadoc Location 那里有個path
          把path下面的地址去掉就OK了!


          原因就是在引用javax.servelet.jar這個包中的javadoc location 位置設置的sun官方網站。這樣每次提示的時候都要去sun官方網站去找doc所以導致MyEclipse會無響應,當禁用網卡或者拔掉網線的時候,就不會出現這種情況http://java.sun.com/j2se/1.5.0/docs/api/



          總之把所有關于java.sun.com的東西都關掉就ok了應該是有5個

          posted @ 2009-12-01 13:39 javaz 閱讀(1639) | 評論 (0)編輯 收藏

          2009年11月28日 #

          swt-jface (1)窗口的組成部分

          import org.eclipse.jface.dialogs.MessageDialog;
          import org.eclipse.swt.SWT;
          import org.eclipse.swt.events.SelectionAdapter;
          import org.eclipse.swt.events.SelectionEvent;
          import org.eclipse.swt.widgets.Button;
          import org.eclipse.swt.widgets.Display;
          import org.eclipse.swt.widgets.Shell;

          public class test_swt {


           public static void main(String[] args) {
              Display display=new Display();
             final Shell shell=new Shell();
             shell.setSize(600,300);
            shell.setText("標題");
            shell.layout();
            //打開主窗口
            shell.open();
            
            //創建其他組件
            Button button = new Button(shell, SWT.NONE);
            //設定按鈕上的字體
            button.setText("確定");
            //設置按鈕文字的提示性語句
            button.setToolTipText("按鈕提示性語句");
            //設定按鈕在主窗口上的位置
            button.setBounds(300, 120, 60, 30);
            button.addSelectionListener(new SelectionAdapter(){//添加按鈕監聽(使用內部類方法)
             public void widgetSelected(SelectionEvent e){
              MessageDialog.openInformation(shell, "彈出窗口標題", "彈出窗口的內容");
              
             }
            });
            
            //如果shell主窗口沒有關閉,則一直循環
            while(!shell.isDisposed()){
             //如果Display不忙,就讓Display處于休眠狀態
             if(!display.readAndDispatch()){
              display.sleep();
             }
            }
            
            //釋放Display的資源
            display.dispose();
           }

          }

          posted @ 2009-11-28 13:46 javaz 閱讀(315) | 評論 (0)編輯 收藏

          2009年11月26日 #

          黑屏白字 SimpleCanvas


          import javax.microedition.lcdui.*;
          import javax.microedition.midlet.*;


          public class SimpleCanvas extends MIDlet{
            private Display display;

              public SimpleCanvas() {
                  display=Display.getDisplay(this);

              }
           
              protected void destroyApp(boolean unconditional)  {
               
                 
              }

              protected void pauseApp() {
                 
              }

              protected void startApp(){
               MyCanvas mc=new MyCanvas();
               display.setCurrent(mc);
              }


          }
          class MyCanvas extends Canvas {

              public void paint(Graphics g){
                g.setColor(0,0,0);
                g.fillRect(0,0,getWidth(),getHeight());
                g.setColor(255, 255,255);
                g.drawString("你好,測試", 100, 100, 0);
              }

          }

          posted @ 2009-11-26 20:06 javaz 閱讀(198) | 評論 (0)編輯 收藏

          僅列出標題  下一頁
          主站蜘蛛池模板: 鄂伦春自治旗| 天峨县| 甘南县| 万荣县| 方城县| 康保县| 兰溪市| 秦安县| 友谊县| 南华县| 伊吾县| 大同市| 丰县| 永福县| 信阳市| 江川县| 武鸣县| 宝应县| 二连浩特市| 剑阁县| 潼关县| 黄石市| 苍山县| 柘荣县| 长治市| 慈利县| 定州市| 唐河县| 图片| 滁州市| 平江县| 舒兰市| 柳州市| 盐源县| 库尔勒市| 浦县| 开封县| 古丈县| 五常市| 平和县| 盘山县|