SWT示例
SWT示例
%0SAI@C_4RF06RH1WT2@64K.png
SWT示例是用SWT编写的有用的小程序。这些通常比SWT Snippets更大,更全面。
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 Example Launcher视图中运行。
- 从Eclipse中作为独立应用程序启动。
- 在Eclipse之外作为独立应用程序运行。
在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示例:
- 安装示例
- 将SWT示例作为视图或使用SWT示例启动器运行
- 运行SWT独立示例
- SWT示例概述
在Eclipse中启动独立的SWT示例
- 将SWT加载到工作区中。
- 通过上面列出的方法之一将SWT示例加载到工作区中。
- 通过选择主类(例如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:
- 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.