ECLIPSE swt實例

SWT示例

SWT示例

%0SAI@C_4RF06RH1WT2@64K.png

SWT示例是用SWT編寫的有用的小程序。這些通常比SWT Snippets更大,更全面。

可以從Eclipse下載頁面下載以下SWT示例:
Vista上的ControlExample
  • ControlExample
  • CustomControlExample
  • 地址簿
  • BrowserExample
  • ClipboardExample
  • DNDExample(拖放)
  • FileViewer
  • GraphicsExample
  • HelloWorld [1-5]
  • HoverHelp
  • ImageAnalyzer
  • JavaViewer
  • LayoutExample
  • PaintExample
  • 文本編輯器
  • OLEExample(僅限win32,OLE)
  • OleWebBrowser(僅限win32,OLE)

ControlExample,CustomControlExample,LayoutExample和PaintExample也可用作Eclipse插件,以下示例作為Eclipse插件提供:

  • org.eclipse.swt.examples.browser.demos項目中的BrowserDemo
  • org.eclipse.swt.examples.browser項目中的WebBrowser

有幾種方法可以下載和運行SWT示例:

在Eclipse中運行SWT示例

  1. 要獲取示例,請訪問 http://download.eclipse.org/eclipse/downloads上的Eclipse下載頁面。
  2. 單擊您想要示例的Eclipse構(gòu)建(即您正在運行的Eclipse構(gòu)建;通常是最新的Stable構(gòu)建)。
  3. 向下滾動,直到看到“示例插件”。閱讀有關(guān)安裝它們的段落,并選擇適合您平臺的下載。
  4. 安裝示例后,您可以在其中找到它們的源代碼eclipse/plugins/org.eclipse.swt.examples.<exampleName>.source_<version>.jar。
  5. 要運行插件SWT示例,請重新啟動Eclipse,轉(zhuǎn)到Window> Show View ...> Other ...并展開“SWT示例”。

或者,您可以使用Eclipse ISV doc中的這些(更詳細的)步驟來下載,安裝和運行Eclipse SWT示例:

  1. 安裝示例
  2. 將SWT示例作為視圖或使用SWT示例啟動器運行
  3. 運行SWT獨立示例
  4. SWT示例概述

在Eclipse中啟動獨立的SWT示例

  1. 將SWT加載到工作區(qū)中。
  2. 通過上面列出的方法之一將SWT示例加載到工作區(qū)中
  3. 通過選擇主類(例如org.eclipse.swt.examples.controlexample.ControlExample)并且選擇運行獨立示例
    運行>運行方式> Java應(yīng)用程序(注:到Eclipse 3.3使用之前 運行>運行方式> SWT的應(yīng)用)。

在Eclipse之外運行獨立的SWT示例

(注意:這些說明僅適用于Eclipse 3.3及更高版本)要獨立運行ControlExample或CustomControlExample:

  1. 轉(zhuǎn)到 http://download.eclipse.org/eclipse/downloads/上的Eclipse下載頁面。

  2. 單擊您想要示例的Eclipse構(gòu)建(即您正在運行的Eclipse / SWT構(gòu)建;通常是最新的Stable Build)。

  3. 向下滾動,直至看到“示例插件”,下載適用于您平臺的.zip,然后將其解壓縮到本地計算機。

  4. 在具有提取的示例插件的目錄中,查找文件org.eclipse.swt.examples_<version>.jar,并將其解壓縮到位。

  5. 打開DOS窗口(在Windows上)或終端窗口(在Mac或Linux上)并導(dǎo)航到此目錄。

  6. 若要運行該示例,請鍵入以下行,并替換相應(yīng)的路徑:
    <pathToYourJRE>\bin\java -classpath <pathOfYourPlatformSWTjar>;.\swtexamples.jar org.eclipse.swt.examples.controlexample.ControlExample

    這是ControlExample。每個控件都有一個選項卡,您可以更改各種樣式等,以查看控件中的更改。要運行CustomControlExample,只需在步驟6中使用類名CustomControlExample而不是ControlExample。

nstalling the examples

Installing examples within Eclipse

The Eclipse SDK examples are found on the Eclipse project update site. To locate and install them into a product:

  1. Open the main install wizard by clicking [
    command link

    Help > Install New Software...](javascript:executeCommand("org.eclipse.equinox.p2.ui.sdk.install")). This opens the Install Wizard.

  2. Select The Eclipse Project Updates site.

  3. Ensure Group items by category is unchecked.

  4. Type "Eclipse SDK Examples" in the search field.

  5. Select "Eclipse SDK Examples" and click Next.

  6. Review the items being installed, and click Next.

  7. Review and accept the license terms, and click Finish.

  8. Click Yes when asked to exit and restart the workbench for the changes to take effect. The examples are now installed in the workbench. Note: you can also click on Apply Now to dynamically install the examples into the current configuration.

Installing examples manually

To install the examples from a stand-alone zip file:

  1. Download the appropriate Eclipse SDK Example zip file from the Eclipse project web site at http://download.eclipse.org/eclipse.
  2. Extract the contents of the zip file to a new empty directory inside the <tt>dropins</tt> directory of your Eclipse installation.
  3. Start or restart Eclipse.

You can verify that examples have been installed by looking for File > New > Example... in the workbench menu bar.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容