The Goal
          Keep walking……
          posts - 23,  comments - 1,  trackbacks - 0
          • Model-based adapters

          與SWT widgets一起工作的JFace類可稱為model-based adapters [或helper classes].這些adapter可以分為4類:
          1.Viewers
          將GUI組件中的信息與外觀分離 [與SWT不同]
          2.Actions and contributions
          簡(jiǎn)化了事件的處理,將用戶命令的反應(yīng)與引發(fā)反應(yīng)的事件分離
          3.Image and font registries
          注冊(cè)機(jī)制,資源可以被按需分配和釋放

          4.Dialogs and wizards
          信息框、錯(cuò)誤框、進(jìn)度框與向?qū)Э虻?/font>

          • SET/JFace應(yīng)用程序的三段式結(jié)構(gòu)

          package com.swtjface.Ch2;

          import org.eclipse.jface.window.*;

          import org.eclipse.swt.*;

          import org.eclipse.swt.widgets.*;


          public class HelloSWT_JFace extends ApplicationWindow {

          public HelloSWT_JFace() {

          super(null); //1.Window allocation

          }

          protected Control createContents(Composite parent) {

          Text helloText = new Text(parent, SWT.CENTER);

          helloText.setText("Hello SWT and JFace!");

          parent.pack();

          return parent; //2.Window presentation

          /*處理窗口的設(shè)計(jì),由于ApplicationWindow的可視部分不能被直接access,此方法連同一個(gè)Composite來(lái)控制GUI的顯示,此container對(duì)象[Composite]是所有被加入應(yīng)用程序的GUI組件的父件*/

          }

          public static void main(String[] args) {

          HelloSWT_JFace awin = new HelloSWT_JFace();

          awin.setBlockOnOpen(true);

          awin.open();

          Display.getCurrent().dispose();? //3.Window operation

          /*負(fù)責(zé)GUI的實(shí)際運(yùn)作。在分派好ApplicationWindow的資源之后,main方法使窗口顯示,當(dāng)setBlockOnOpen()方法以一個(gè)true參數(shù)被調(diào)用的時(shí)候,窗口關(guān)閉。然后ApplicationWindow的open()方法被調(diào)用,根據(jù)createContent()方法所返回的Composite來(lái)顯示窗口。然后程序通過(guò)dispose()方法釋放GUI的Display實(shí)例.因?yàn)榇顺绦蛑械乃衱idget都是display的child,所以一旦釋放Display,所有的widget都被釋放*/

          }

          }

          • SWT與SWT/JFace的區(qū)別

          SWT將GUI的外觀和操作都放在它的Shell類里,而SWT/JFace卻將兩者分離開(kāi)來(lái)了,其中外觀由createContents()方法內(nèi)的Compsite來(lái)控制,而操作部分大體上是通過(guò)ApplicationWindow類的實(shí)例來(lái)實(shí)現(xiàn)的。

          • ApplicationWindow

          SWT/JFace同樣需要一個(gè)單獨(dú)的Display實(shí)例,但是只要ApplicationWindow通過(guò)一個(gè)null參數(shù)來(lái)構(gòu)建,那么就會(huì)創(chuàng)建它自己的Shell。參閱下圖

          ApplicationWindow在Shell的基礎(chǔ)上提供了更多的途徑來(lái)設(shè)計(jì)窗口,其相關(guān)方法如下:
          addMenuBar()
          Configures the window with a top-level menu
          addToolBar()
          Adds a toolbar beneath the main menu
          addStatusLine()
          Creates a status area at the bottom of the window
          setStatus(String)
          Displays a message in the status area
          getSeparator()
          Returns the line separating the menu from the window
          setDefaultImage(Image)
          Displays an image when the application has no shell
          setExceptionHandler(IExceptionHandler)
          Configures the application to handle exceptions according to the specified interface

          posted on 2006-03-15 17:07 JOO 閱讀(327) 評(píng)論(0)  編輯  收藏 所屬分類: SWT & JFace IN ACTION
          Hit the target!

          <2006年3月>
          2627281234
          567891011
          12131415161718
          19202122232425
          2627282930311
          2345678

          常用鏈接

          留言簿(2)

          隨筆分類(23)

          隨筆檔案(22)

          文章檔案(1)

          相冊(cè)

          Neighbor

          搜索

          •  

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 织金县| 乌拉特前旗| 安吉县| 长沙县| 永安市| 岫岩| 厦门市| 乌鲁木齐市| 沙洋县| 通化县| 慈利县| 高邑县| 贵阳市| 香港 | 五河县| 抚州市| 普定县| 志丹县| 西乡县| 文昌市| 绥德县| 海阳市| 罗定市| 灵宝市| 昆山市| 罗源县| 罗城| 沐川县| 黄山市| 辛集市| 牟定县| 安陆市| 天长市| 武功县| 汤阴县| 仁寿县| 大名县| 抚远县| 内江市| 巩留县| 穆棱市|