Hexise's Blog

          業(yè)精于勤荒于嬉 行成于思?xì)в陔S
          posts - 13, comments - 12, trackbacks - 0, articles - 0
            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          日歷

          <2006年12月>
          262728293012
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          公告

          Free Domain Name Registration

          搜索

          •  

          最新評(píng)論

          設(shè)置JFace的Dialog樣式

          Posted on 2006-12-29 12:53 Hexise 閱讀(1662) 評(píng)論(0)  編輯  收藏

          經(jīng)常性的,自己設(shè)計(jì)的對(duì)話框無(wú)法改變大小,沒(méi)有最大化最小化按鈕,等等.在哪里設(shè)置這些屬性呢?

          JFace的Dialog繼承于Window類,該類中有一方法,設(shè)置Shell的樣式.

          setShellStyle

          protected void setShellStyle(int?newShellStyle)
          Sets the shell style bits. This method has no effect after the shell is created.

          The shell style bits are used by the framework method createShell when creating this window's shell.

          Parameters:
          newShellStyle - the new shell style bits


          在Dialog的構(gòu)造函數(shù)中調(diào)用該方法,即可更改Dialog的樣式.下為一例:

          import ?org.eclipse.jface.dialogs.Dialog;
          import ?org.eclipse.swt.SWT;
          import ?org.eclipse.swt.browser.Browser;
          import ?org.eclipse.swt.layout.GridData;
          import ?org.eclipse.swt.widgets.Composite;
          import ?org.eclipse.swt.widgets.Control;
          import ?org.eclipse.swt.widgets.Shell;

          public ? class ?BrowserDialog? extends ?Dialog? {

          ????
          private ?String?url;

          ????
          public ?BrowserDialog(Shell?parent,?String?url)? {
          ????????
          super (parent);
          ????????setShellStyle(getShellStyle()?
          | ?SWT.RESIZE? | ?SWT.MAX);
          ????????
          this .url? = ?url;
          ????}


          ????
          protected ?Control?createContents(Composite?parent)? {
          ????????Browser?browser?
          = ? new ?Browser(parent,?SWT.NONE);
          ????????browser.setUrl(url);
          ????????GridData?gd?
          = ? new ?GridData(GridData.FILL_BOTH);
          ????????gd.minimumWidth?
          = ? 600 ;
          ????????gd.minimumHeight?
          = ? 400 ;
          ????????browser.setLayoutData(gd);
          ????????
          return ?browser;
          ????}

          }

          import ?org.eclipse.swt.SWT;
          import ?org.eclipse.swt.widgets.Display;
          import ?org.eclipse.swt.widgets.Shell;

          public ? class ?TestDialog? {

          ????
          public ? static ? void ?main(String[]?args)? {

          ????????
          final ?Shell?shell? = ? new ?Shell(SWT.DIALOG_TRIM? | ?SWT.RESIZE? | ?SWT.MIN? | ?SWT.MAX);
          ????????
          final ?Display?display? = ?shell.getDisplay();

          ????????String?path?
          = ? " C:/Temp/log.html " ;
          ????????BrowserDialog?dlg?
          = ? new ?BrowserDialog(shell,?path);
          ????????dlg.open();

          ????????
          while ?( ! shell.isDisposed())? {
          ????????????
          if ?( ! display.readAndDispatch())? {
          ????????????????display.sleep();
          ????????????}

          ????????}


          ????}

          }

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


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 新龙县| 宁津县| 酉阳| 汶上县| 奉化市| 宜兰县| 阿拉尔市| 岑溪市| 甘泉县| 宁晋县| 濮阳市| 揭阳市| 洛南县| 恭城| 西和县| 乡宁县| 平遥县| 芮城县| 武功县| 广安市| 雅安市| 宾阳县| 宁海县| 高碑店市| 平乡县| 炉霍县| 辽宁省| 江城| 弥勒县| 锦州市| 大英县| 沙雅县| 宜川县| 营口市| 马鞍山市| 普安县| 凉山| 长治县| 长治市| 壶关县| 石柱|