<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    The Goal
    Keep walking……
    posts - 23,  comments - 1,  trackbacks - 0
    • SWT應用程序的三段式結構:

    package com.swtjface.Ch2;

    import org.eclipse.swt.*;

    import org.eclipse.swt.widgets.*;

    public class HelloSWT {

    public static void main (String [] args) {

    Display display = new Display();

    Shell shell = new Shell(display); //1.Allocation and initialization。
    /*生成一個DisplayShell類的實例,GUI獲取底層平臺的資源并開辟了一個主窗口。*/

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

    helloText.setText("Hello SWT!");

    helloText.pack();//2.Adding widgets to the shell

    /* Shell 上加入一個文本小部件。The code in this section also sets the parameters for these widgets, containers, and events to make sure they look and act as required.其中pack()方法是tell the Shell and Text components to use only as much space as they need.*/

    shell.pack();

    shell.open();

    while (!shell.isDisposed()){

    if (!display.readAndDispatch()) display.sleep();

    }

    display.dispose(); //3.GUI operation

    /*一旦Shell的open()方法被調用,應用程序的主窗口和其子部件都會被呈現。只要Shell保持在打開狀態,Display實例就會通過它的readAndDispatch()方法來追蹤在操作系統事件隊列中的相關用戶事件。當窗口關閉時,與Display對象(包括Shell以及其子部件等)相聯系的資源就全部釋放*/

    }

    }

    • Display 類

    Display 類并不是可見的,但它負責監管著 GUI 的資源并管理著和操作系統的通信。它不光要關注著它自己的窗口是如何顯示、移動和重畫的,還同時要確保諸如鼠標點擊、鍵盤敲擊等事件送達widgets并去處理它們。

    是任何 SWT JFace 應用程序的承載著,無論你是用 SWT/JFace 開發或是單用 SWT 開發,你必須在你的程序中包含這個類的一個實例。

    Display 類的主要任務就是負責將你的代碼重的 SWT JFace 命令翻譯成底層的命令來調取操作系統。 這一過程包含了兩部分: 1.Display 對象構建一個代表著操作系統平臺的 OS 類的實例;這個類通過一系列被稱之為native methods的特殊 Java 程序提供了接觸計算機底層資源的途徑。2. 這個 Display 對象使用這些方法來直接指令操作系統并向應用程序傳達用戶動作。

    if any features in your operating system aren’t incorporated into SWT, you can use the Java Native Interface to add them yourself.All it requires is a native Java method in the SWT package and a C function in the native graphics library that calls the operating system.

    • Display 類的方法

    1.Display()--Allocates platform resources and creates a Display object
    must be used in any SWT-based GUI.它產生一個Display類的實例并將其和GUI相聯系
    2.getCurrent()--Returns the user-interface thread
    must be used in any SWT-based GUI.它返回一個應用程序的主線程,用戶界面線程,通常和dispose()一起使用來結束Display的操作。
    3.readAndDispatch()--Display object interprets events and passes them to receiver
    enable the application to receive notifications from the operating system whenever the user takes an action associated with the GUI.
    accesses the operating system’s event queue and determines whether any of the user’s actions are related to the GUI.
    Using this method, the HelloSWT class knows whether the user has decided to dispose of the Shell. If so, the method returns TRUE, and the application ends. Otherwise, the Display object invokes its sleep() method, and the application continues waiting.
    4.sleep()--Display object waits for events
    enable the application to receive notifications from the operating system whenever the user takes an action associated with the GUI.

  • Shell 類
  • The Shell class accesses the operating system through the OS class to an extent, but only to keep track of opening, activating, maximizing, minimizing, and closing the main window.

    The main function of the Shell class is to provide a common connection point for the containers, widgets, and events that need to be integrated into the GUI. Shell serves as the parent class to these components.

    attached to the Display的shell--top-level shells
    NOT directly attached to the Display instance的shell--secondary shell

    在你的GUI之內,你可以設定shell或其他小部件的風格參數值,若是多個值則可以用“|”相連.除了提到的屬性,默認為“SHELL_TRIM”。

    SHELL_TRIM--有一個標題欄(SWT.TITLE)和用戶可以最小化SWT.MIN)、最大化(SWT.MAX)、改變尺寸(SWT.RESIZE)和關閉(SWT.CLOSE)
    DIALOG_TRIM--有一個標題欄、一個活動區的邊界(SWT.BORDER)和被關閉的能力

    你還可以確定
    shell的形態,以限定用戶修改shell的modality,如A modal dialog box不能被移動或是改變尺寸,只可以使用給予的按鈕關閉或是取消。


    NOT?every platform can render these properties in GUI components.

    posted on 2006-03-15 13:51 JOO 閱讀(350) 評論(0)  編輯  收藏 所屬分類: SWT & JFace IN ACTION
    Hit the target!

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

    常用鏈接

    留言簿(2)

    隨筆分類(23)

    隨筆檔案(22)

    文章檔案(1)

    相冊

    Neighbor

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 四虎影视精品永久免费| 日韩亚洲变态另类中文| 亚洲AV中文无码乱人伦| 亚洲狠狠成人综合网| 黄床大片30分钟免费看| 猫咪免费人成网站在线观看| 四虎影视永久免费观看地址| 久久亚洲精品高潮综合色a片| 噜噜嘿在线视频免费观看| 亚洲人成网站在线在线观看| 国产无遮挡裸体免费视频| 免费播放国产性色生活片| 亚洲人成人网站在线观看| tom影院亚洲国产一区二区| 亚洲日本va一区二区三区| 好男人看视频免费2019中文| 日韩亚洲人成网站| 亚洲免费网站观看视频| 久久精品国产96精品亚洲| 8x8x华人永久免费视频| 亚洲色少妇熟女11p| 亚欧在线精品免费观看一区| 精品丝袜国产自在线拍亚洲| 日本一道本高清免费| 中文字幕乱码亚洲无线三区| 国产男女猛烈无遮挡免费视频网站| 亚洲av日韩av永久无码电影| 亚洲色大成网站www永久一区| 久久99精品视免费看| 亚洲美女高清一区二区三区 | 亚洲自偷自偷精品| 性生大片视频免费观看一级| 成人免费看吃奶视频网站| 亚洲视频一区在线| 四虎1515hm免费国产| 免费人成毛片动漫在线播放| 亚洲精品无码成人| 亚洲AV无码久久| 性做久久久久免费观看| 免费污视频在线观看| 亚洲成熟丰满熟妇高潮XXXXX|