Hexise's Blog

          業精于勤荒于嬉 行成于思毀于隨
          posts - 13, comments - 12, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          日歷

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

          公告

          Free Domain Name Registration

          搜索

          •  

          最新評論

          設置JFace的Dialog樣式

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

          經常性的,自己設計的對話框無法改變大小,沒有最大化最小化按鈕,等等.在哪里設置這些屬性呢?

          JFace的Dialog繼承于Window類,該類中有一方法,設置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的構造函數中調用該方法,即可更改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();
          ????????????}

          ????????}


          ????}

          }

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


          網站導航:
           
          主站蜘蛛池模板: 宜城市| 环江| 临朐县| 武川县| 永和县| 遵义县| 伊吾县| 东阿县| 昭苏县| 蒲江县| 嘉黎县| 绥化市| 红安县| 江北区| 东方市| 海城市| 莒南县| 咸丰县| 宁阳县| 封开县| 台南市| 安新县| 称多县| 郴州市| 林甸县| 商河县| 额尔古纳市| 大悟县| 拜泉县| 合作市| 临高县| 辽阳市| 金昌市| 如皋市| 万州区| 子长县| 台州市| 洞口县| 米易县| 视频| 泰兴市|