七年的愛(ài)
          手中沒(méi)有劍,我如何保護(hù)她;手中握著劍,我如何抱緊她!
          posts - 7,comments - 3,trackbacks - 0
               關(guān)于swt的歡迎界面的例子,網(wǎng)上找了很就沒(méi)有。后來(lái)自己就想用一個(gè)沒(méi)有邊框的shell加上一個(gè)滾動(dòng)條來(lái)實(shí)現(xiàn),具體的怎么用滾動(dòng)條來(lái)檢視后臺(tái),我還是沒(méi)找到例子,現(xiàn)在就用一個(gè)白癡滾動(dòng)條來(lái)暫時(shí)代替一下。白癡滾動(dòng)條也就是想windows啟動(dòng)界面時(shí)出現(xiàn)的那樣,一直不停的滾呀滾,呵呵。代碼如下,

          package com.sinosafe.swtdemo.welcome;

          import org.eclipse.swt.SWT;
          import org.eclipse.swt.graphics.Image;
          import org.eclipse.swt.layout.FillLayout;
          import org.eclipse.swt.layout.GridData;
          import org.eclipse.swt.layout.GridLayout;
          import org.eclipse.swt.widgets.*;
          /**
           *
           * @author zhong39
           * 一個(gè)簡(jiǎn)單的啟動(dòng)界面的例子
           *
           */

          public class WelcomeInterface {
           
           private static Shell shell;

           public static void main(String[] args) {
            Display display = new Display();
            shell = new Shell(display, SWT.NO_TRIM |SWT.ON_TOP);
            createContents(shell);
            shell.setBounds(400, 200, 310, 250);
            shell.open();
            while (!shell.isDisposed()) {
             if (!display.readAndDispatch())
              display.sleep();
            }
            display.dispose();
           }
           protected static void createContents(Shell shell) {
            shell.setLayout(new FillLayout());
            Composite cm = new Composite(shell ,SWT.None);
            cm.setLayout(new GridLayout(1,false));
            Image ico = new Image(Display.getDefault(), "icons/welcome.gif");
            Label label = new Label(cm,SWT.None);
            label.setImage(ico);
            final ProgressBar progressBar = new ProgressBar(cm, SWT.INDETERMINATE);
            progressBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            
           }
          }


          具體在我一個(gè)應(yīng)用程序中怎么使用,
          我暫時(shí)的想法是在程序啟動(dòng)界面開(kāi)始時(shí)先傳一個(gè)display過(guò)去,先啟動(dòng)這個(gè)界面,在啟動(dòng)應(yīng)用程序界面,和要加載的數(shù)據(jù),最后調(diào)用welcomeClose方法來(lái)關(guān)閉,下面是,修改過(guò)的代碼.

          package com.sinosafe.premium.application;

          import org.eclipse.swt.SWT;
          import org.eclipse.swt.graphics.Image;
          import org.eclipse.swt.layout.FillLayout;
          import org.eclipse.swt.layout.GridData;
          import org.eclipse.swt.layout.GridLayout;
          import org.eclipse.swt.widgets.*;

          /**
           *
           * @author zhong39
           *
           */

          public class WelcomeInterface {
           
           private Shell welcomeShell;
           
           public void open(Display display) {
            //Display display = new Display();
            welcomeShell = new Shell(display, SWT.NO_TRIM);
            createContents(welcomeShell);
            welcomeShell.setBounds(400, 200, 310, 250);
            welcomeShell.open();
           }
           protected  void createContents(Shell shell) {
            shell.setLayout(new FillLayout());
            Composite cm = new Composite(shell ,SWT.None);
            cm.setLayout(new GridLayout(1,false));
            Image welcome = new Image(Display.getDefault(), "images/welcome.gif");
            Label label = new Label(cm,SWT.None);
            label.setImage(welcome);
            ProgressBar progressBar = new ProgressBar(cm, SWT.INDETERMINATE);
            progressBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            
           }
           public void welcomeClose(){
            welcomeShell.close();
           }
          }

          總的來(lái)說(shuō)就是shell的風(fēng)格沒(méi)有邊框就是,其他的沒(méi)什么特別的,還有圖片的話,這個(gè)大家一定得弄個(gè)上去,不然的話肯定是顯示不出來(lái)了。

          好了,第開(kāi)天辟地的第一篇就寫(xiě)個(gè)浮淺的東西,主要是這方面的網(wǎng)上好難早,所以我寫(xiě)的關(guān)于這方面的我個(gè)人的愚見(jiàn),希望能節(jié)省到有這方面需要的人的時(shí)間。

          posted on 2007-09-10 13:08 逝去的圣男 閱讀(1014) 評(píng)論(1)  編輯  收藏

          FeedBack:
          # re: swt 歡迎界面的制作
          2008-10-14 15:38 | 秀逗

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 边坝县| 石首市| 潮州市| 慈利县| 河北省| 静海县| 新河县| 观塘区| 青铜峡市| 永寿县| 黄平县| 新津县| 噶尔县| 奉新县| 芜湖市| 泽普县| 平舆县| 天水市| 镇远县| 法库县| 雷山县| 收藏| 新郑市| 鄂温| 安溪县| 英超| 集安市| 宜州市| 右玉县| 衡阳县| 蒙自县| 丰宁| 雷山县| 平安县| 永宁县| 兴业县| 上蔡县| 仪征市| 闻喜县| 甘洛县| 蒙阴县|