SWT示例
SWT示例
SWT示例是用SWT編寫的有用的小程序台颠。這些通常比SWT Snippets更大,更全面症昏。
可以從Eclipse下載頁面下載以下SWT示例:- 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示例
- 要獲取示例培己,請訪問 http://download.eclipse.org/eclipse/downloads上的Eclipse下載頁面碳蛋。
- 單擊您想要示例的Eclipse構建(即您正在運行的Eclipse構建;通常是最新的Stable構建)。
- 向下滾動省咨,直到看到“示例插件”肃弟。閱讀有關安裝它們的段落,并選擇適合您平臺的下載零蓉。
- 安裝示例后笤受,您可以在其中找到它們的源代碼
eclipse/plugins/org.eclipse.swt.examples.<exampleName>.source_<version>.jar
。 - 要運行插件SWT示例敌蜂,請重新啟動Eclipse箩兽,轉到Window> Show View ...> Other ...并展開“SWT示例”。
或者章喉,您可以使用Eclipse ISV doc中的這些(更詳細的)步驟來下載汗贫,安裝和運行Eclipse SWT示例:
在Eclipse中啟動獨立的SWT示例
- 將SWT加載到工作區(qū)中身坐。
- 通過上面列出的方法之一將SWT示例加載到工作區(qū)中。
- 通過選擇主類(例如org.eclipse.swt.examples.controlexample.ControlExample)并且選擇運行獨立示例
運行>運行方式> Java應用程序(注:到Eclipse 3.3使用之前 運行>運行方式> SWT的應用)落包。
在Eclipse之外運行獨立的SWT示例
(注意:這些說明僅適用于Eclipse 3.3及更高版本)要獨立運行ControlExample或CustomControlExample:
轉到 http://download.eclipse.org/eclipse/downloads/上的Eclipse下載頁面部蛇。
單擊您想要示例的Eclipse構建(即您正在運行的Eclipse / SWT構建;通常是最新的Stable Build)。
向下滾動咐蝇,直至看到“示例插件”涯鲁,下載適用于您平臺的.zip,然后將其解壓縮到本地計算機有序。
在具有提取的示例插件的目錄中抹腿,查找文件
org.eclipse.swt.examples_<version>.jar
,并將其解壓縮到位旭寿。打開DOS窗口(在Windows上)或終端窗口(在Mac或Linux上)并導航到此目錄幢踏。
-
若要運行該示例,請鍵入以下行许师,并替換相應的路徑:
<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:
-
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.
Select The Eclipse Project Updates site.
Ensure Group items by category is unchecked.
Type "Eclipse SDK Examples" in the search field.
Select "Eclipse SDK Examples" and click Next.
Review the items being installed, and click Next.
Review and accept the license terms, and click Finish.
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:
- Download the appropriate Eclipse SDK Example zip file from the Eclipse project web site at http://download.eclipse.org/eclipse.
- Extract the contents of the zip file to a new empty directory inside the <tt>dropins</tt> directory of your Eclipse installation.
- Start or restart Eclipse.
You can verify that examples have been installed by looking for File > New > Example... in the workbench menu bar.