﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-Java 学习</title><link>http://www.blogjava.net/cpenet/</link><description>坚持不懈，打通--&gt;软件—控制—机械</description><language>zh-cn</language><lastBuildDate>Wed, 29 Apr 2026 00:05:06 GMT</lastBuildDate><pubDate>Wed, 29 Apr 2026 00:05:06 GMT</pubDate><ttl>60</ttl><item><title>SWT组件的生命周期（续一个简单的SWT程序实例及详解）</title><link>http://www.blogjava.net/cpenet/archive/2006/07/04/56539.html</link><dc:creator>燕然</dc:creator><author>燕然</author><pubDate>Tue, 04 Jul 2006 06:52:00 GMT</pubDate><guid>http://www.blogjava.net/cpenet/archive/2006/07/04/56539.html</guid><wfw:comment>http://www.blogjava.net/cpenet/comments/56539.html</wfw:comment><comments>http://www.blogjava.net/cpenet/archive/2006/07/04/56539.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/cpenet/comments/commentRss/56539.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cpenet/services/trackbacks/56539.html</trackback:ping><description><![CDATA[
		<font color="#000000" size="2">上一篇详细介绍了一个SWT实例，这一篇接下来介绍SWT组件的生命周期<br />本文地址：<a id="Editor_Edit_hlEntryLink" title="view: SWT组件的生命周期（续一个简单的SWT程序实例及详解）" href="/cpenet/archive/2006/07/04/56539.html" target="_blank"><font color="#002c99">http://www.blogjava.net/cpenet/archive/2006/07/04/56539.html</font></a><br /><br /></font>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<font color="#000000">
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">本篇译自《</span>
								<span lang="EN-US">Eclipse.Building.Commercial.Quality.Plug.ins.2nd.Edition</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">》第四章第二节，希望对入门者有所帮助。</span>
						</font>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?>
						<o:p>
								<font color="#000000" size="2"> </font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.1pt; mso-char-indent-count: 2.0">
				<b style="mso-bidi-font-weight: normal">
						<font size="2">
								<font color="#000000">
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">组件的生命周期</span>
										<span lang="EN-US">
												<o:p>
												</o:p>
										</span>
								</font>
						</font>
				</b>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<font color="#000000">
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设计</span>
								<span lang="EN-US">SWT</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的一个目标就是小而灵巧。为了达到这个目标，一个基本的设计策略，就是尽可能的使组件的状态存储在平台组件中而不是存储在</span>
								<span lang="EN-US">SWT</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">组件中</span>
								<span lang="EN-US">(</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">这句话，我不理解，也翻译的不明白，附原文：</span>
								<span lang="EN-US">To achieve this, a basic design decision was made that as much widget state as possible would be stored in the platform widget rather than in the SWT widget.)</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。这与</span>
								<span lang="EN-US">Swing</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">形成显著的对比，</span>
								<span lang="EN-US">Swing</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</span>
								<span lang="EN-US">Swing</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">组件中维护了所有的组件状态。</span>
								<span lang="EN-US">(</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">可能是这样：</span>
								<span lang="EN-US">SWT</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">把各个组件的状态交给系统平台来管理，而</span>
								<span lang="EN-US">Swing</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">自己管理各个</span>
								<span lang="EN-US">Swing</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">组件的状态，这样</span>
								<span lang="EN-US">Swing</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就复杂，耗费的资源，内存的需求也多，不知道是不是</span>
								<span lang="EN-US" style="FONT-FAMILY: Wingdings; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-char-type: symbol; mso-symbol-font-family: Wingdings">
										<span style="mso-char-type: symbol; mso-symbol-font-family: Wingdings">J</span>
								</span>
								<span lang="EN-US">)</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">。通过不把系统平台级别的组件信息复制过来自己维护，</span>
								<span lang="EN-US">SWT</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就非常的小巧而且对内存的需求也相应少。</span>
						</font>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0">
				<font size="2">
						<font color="#000000">
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">达到这个目的所付出的代价就是</span>
								<span lang="EN-US">SWT</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的组件不能够自己独立存在。当一个</span>
								<span lang="EN-US">SWT</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">组件被创建时，同时立即在系统平台下也创建了该组件的对应体。接下来，几乎所有对该组件的信息状态请求都会由平台来处理。</span>
						</font>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0">
				<font size="2">
						<font color="#000000">
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">大部分的系统平台在创建一个组件时，需要该组件明确的父组件的上下文，所以</span>
								<span lang="EN-US">SWT</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">需要一个父组件来最为它的构造声明。许多平台在创建组件时还需要该组件的特定风格参数的设定。例如：按钮有复选框，单选框，简单按钮和文本域有单行和多行之分。</span>
						</font>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0">
				<a name="iddle7534">
				</a>
				<a name="iddle6945">
				</a>
				<font size="2">
						<font color="#000000">
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在</span>
								<span lang="EN-US">SWT</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">类中，风格位段用整数类型来定义且不会更改。风格参数被组织在一起，其它各种构造器传递着这些参数来创建一个组件的初始风格。注意到，所有的平台并不支持所有的风格，所以在很多情况下，被请求的风格被认为是一种提示，它或许会或许不会对一个特殊的平台产生影响。</span>
						</font>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0">
				<font size="2">
						<font color="#000000">
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">当</span>
								<span lang="EN-US">SWT</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">组件不在需要时，一些平台要求作出明确的释放。对于组件本身和一些资源</span>
								<span lang="EN-US">(</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">例如：图形，字体，颜色</span>
								<span lang="EN-US">)</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">而言，他们已经具备了系统的这个要求。基本的规则是：<b style="mso-bidi-font-weight: normal">如果你创建了一个组件，就要使用</b></span>
								<b style="mso-bidi-font-weight: normal">
										<span lang="EN-US">dispose()</span>
								</b>
								<b style="mso-bidi-font-weight: normal">
										<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方法来撤销这个组件。如果你使用了一些系统资源，例如系统颜色，你就不需要释放他们。</span>
								</b>
						</font>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0">
				<font size="2">
						<font color="#000000">
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">幸运的，<b style="mso-bidi-font-weight: normal">当一个组件被释放的，它的所有子组件会自动地被释放</b>。这意味着，如果你释放了一个</span>
								<span lang="EN-US">shell</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，那么所有</span>
								<span lang="EN-US">shell</span>
								<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">包含的组件都会被自动释放。</span>
						</font>
				</font>
		</p>
<img src ="http://www.blogjava.net/cpenet/aggbug/56539.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cpenet/" target="_blank">燕然</a> 2006-07-04 14:52 <a href="http://www.blogjava.net/cpenet/archive/2006/07/04/56539.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个简单的SWT程序实例及详解</title><link>http://www.blogjava.net/cpenet/archive/2006/07/03/56407.html</link><dc:creator>燕然</dc:creator><author>燕然</author><pubDate>Mon, 03 Jul 2006 12:09:00 GMT</pubDate><guid>http://www.blogjava.net/cpenet/archive/2006/07/03/56407.html</guid><wfw:comment>http://www.blogjava.net/cpenet/comments/56407.html</wfw:comment><comments>http://www.blogjava.net/cpenet/archive/2006/07/03/56407.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/cpenet/comments/commentRss/56407.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cpenet/services/trackbacks/56407.html</trackback:ping><description><![CDATA[
		<p class="MsoNormal">
				<font size="2">
						<span style="FONT-FAMILY: 宋体">本文译自《</span>
						<span lang="EN-US">Eclipse.Building.Commercial.Quality.Plug.ins.2nd.Edition</span>
						<span style="FONT-FAMILY: 宋体">》第四章第二节，详细解释了</span>
						<span lang="EN-US">SWT</span>
						<span style="FONT-FAMILY: 宋体">程序的语句，希望对入门者有所帮助。</span>
				</font>
		</p>
		<p class="MsoNormal">
				<span lang="EN-US">
						<font size="2">
								<?xml:namespace prefix = o /?>
								<o:p> </o:p> 本文地址：<a id="Editor_Edit_hlEntryLink" title="view: 一个简单的SWT程序实例及详解" href="/cpenet/archive/2006/07/03/56407.html" target="_blank"><font color="#002c99">http://www.blogjava.net/cpenet/archive/2006/07/03/56407.html</font></a></font>
				</span>
		</p>
		<p class="MsoNormal">
				<font size="2">
						<span style="FONT-FAMILY: 宋体">让我们从简单的</span>
						<span lang="EN-US">HelloWorld</span>
						<span style="FONT-FAMILY: 宋体">应用程序开始。</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN-LEFT: 21pt; TEXT-INDENT: -21pt">
				<font size="2"> <span lang="EN-US"><span>一、</span></span><span style="FONT-FAMILY: 宋体">将</span><span lang="EN-US">SWT</span><span style="FONT-FAMILY: 宋体">添加到工程的类路径中</span></font>
		</p>
		<p class="doctext" style="TEXT-INDENT: 24pt">
				<a name="d0e19218">
				</a>
				<font size="2">首先建立一个<span lang="EN-US">java</span>工程。在开始使用<span lang="EN-US">SWT</span>之前，需要将<span lang="EN-US">SWT</span>库文件添加到工程的类路径中。步骤如下： </font>
		</p>
		<p class="doclist" style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt">
				<font size="2">
						<span lang="EN-US">
								<span>1.<span style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal">    </span></span>
						</span>下载<span lang="EN-US">SWT</span>。在<span lang="EN-US">Eclipse SDK</span>的下载页面中，提供了独立版本的<span lang="EN-US">SWT</span>下载。找到标有<span class="docemphstrong"><b><span lang="EN-US">SWT Binary and Source</span></b>的栏目。下载适合你操作系统的版本，不用解压，直接保存到硬盘中。</span></font>
		</p>
		<p class="doclist" style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt">
				<a name="d0e19257">
				</a>
				<a name="d0e19256">
				</a>
				<font size="2">
						<span lang="EN-US">
								<span>2.<span style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal">    </span></span>
						</span>在<span lang="EN-US">Eclipse</span>菜单栏，选择<b><span lang="EN-US">File-</span>〉<span lang="EN-US">Import...</span></b>打开导入向导 </font>
		</p>
		<p class="doclist" style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt">
				<a name="d0e19274">
				</a>
				<font size="2">
						<span lang="EN-US">
								<span>3.<span style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal">    </span></span>
						</span>选择<span class="docemphstrong"><b><span lang="EN-US">Existing Projects into Workspace</span></b>，点击<b><span lang="EN-US">Next</span></b>按钮</span></font>
		</p>
		<p class="doclist" style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt">
				<font size="2">
						<span lang="EN-US">
								<span>4.<span style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal">    </span></span>
						</span>选择 <span class="docemphstrong"><b><span lang="EN-US">Select archive file</span></b></span><span lang="EN-US"></span>并使用 <span class="docemphstrong"><b><span lang="EN-US">Browse...</span></b></span><b><span lang="EN-US"></span></b>按钮来找到你刚才下载的<span lang="EN-US">SWT</span>文件。 </font>
		</p>
		<p class="doclist" style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt">
				<font size="2"> <span lang="EN-US"><span>5.<span style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal">    </span></span></span>点击<b><span class="docemphstrong"><span lang="EN-US">Finish</span></span></b><span lang="EN-US"></span>按钮，完成<span lang="EN-US">SWT</span>导入。 </font>
		</p>
		<p class="doclist" style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt">
				<font size="2"> <span lang="EN-US"><span>6.<span style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal">    </span></span></span>右键点击你建立的工程，选择<span class="docemphstrong"><b><span lang="EN-US">Properties</span></b></span><span lang="EN-US"></span></font>
				<a name="d0e19317">
				</a>
				<a name="d0e19316">
				</a>
				<font size="2">来打开<span class="docemphstrong"><span lang="EN-US">Properties</span>对话框。</span></font>
		</p>
		<p class="doclist" style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt">
				<font size="2"> <span lang="EN-US"><span>7.<span style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal">    </span></span></span>选择 <span class="docemphstrong"><b><span lang="EN-US">Java Build Path </span></b><span lang="EN-US">-&gt;<b> Projects</b></span></span><b><span lang="EN-US"> tab</span></b><span lang="EN-US"></span>并点击<span class="docemphstrong"><b><span lang="EN-US">Add</span></b></span><span lang="EN-US"></span>按钮<span lang="EN-US">.</span></font>
		</p>
		<p class="doclist" style="MARGIN-LEFT: 36pt; TEXT-INDENT: -18pt">
				<font size="2"> <span lang="EN-US"><span>8.<span style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal">    </span></span></span>选择 <span class="docemphstrong"><span lang="EN-US">org.eclipse.swt</span></span><span lang="EN-US"></span>工程， 点击 <span class="docemphstrong"><b><span lang="EN-US">OK</span></b></span><span lang="EN-US"></span>，完成添加<span lang="EN-US">SWT</span>库到你的工程中<span lang="EN-US">(</span>见图<span lang="EN-US">1).</span></font>
		</p>
		<p class="MsoNormal">
				<span lang="EN-US">
						<?xml:namespace prefix = v /?>
						<v:shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600">
								<v:stroke joinstyle="miter">
								</v:stroke>
								<v:formulas>
										<v:f eqn="if lineDrawn pixelLineWidth 0">
										</v:f>
										<v:f eqn="sum @0 1 0">
										</v:f>
										<v:f eqn="sum 0 0 @1">
										</v:f>
										<v:f eqn="prod @2 1 2">
										</v:f>
										<v:f eqn="prod @3 21600 pixelWidth">
										</v:f>
										<v:f eqn="prod @3 21600 pixelHeight">
										</v:f>
										<v:f eqn="sum @0 0 1">
										</v:f>
										<v:f eqn="prod @6 1 2">
										</v:f>
										<v:f eqn="prod @7 21600 pixelWidth">
										</v:f>
										<v:f eqn="sum @8 21600 0">
										</v:f>
										<v:f eqn="prod @7 21600 pixelHeight">
										</v:f>
										<v:f eqn="sum @10 21600 0">
										</v:f>
								</v:formulas>
								<v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f">
								</v:path>
								<o:lock aspectratio="t" v:ext="edit">
								</o:lock>
						</v:shapetype>
						<font size="2">
								<img height="390" alt="{26F7CFAE-1A69-42BA-A826-4576DB987FD5}.BMP" src="http://www.blogjava.net/images/blogjava_net/cpenet/%7B26F7CFAE-1A69-42BA-A826-4576DB987FD5%7D.BMP" width="599" border="0" /> </font>
				</span>
				<font size="2">
				</font>
		</p>
		<p class="MsoNormal">
				<font size="2">
						<span lang="EN-US">
								<span>                              </span>
						</span>
						<span style="FONT-FAMILY: 宋体">图</span>
						<span lang="EN-US">1</span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">二、 <a name="iddle6850"></a><span lang="EN-US">SWT </span>代码<span lang="EN-US"><o:p></o:p></span></span>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">
						<font size="2">现在在你建立的<span lang="EN-US">java</span>工程中，新建一个<span lang="EN-US">java</span>文件，取名为 </font>
						<a name="iddle6566">
						</a>
						<a name="iddle6494">
						</a>
						<a name="iddle6437">
						</a>
						<a name="iddle6361">
						</a>
						<a name="iddle5934">
						</a>
						<a name="iddle6699">
						</a>
						<a name="iddle6620">
						</a>
						<a name="iddle5088">
						</a>
						<a name="iddle4289">
						</a>
						<a name="iddle2382">
						</a>
						<font size="2">
								<span lang="EN-US">HelloWorld</span>。在<span lang="EN-US">HelloWorld.java</span>文件中把<span lang="EN-US">main()</span>方法覆盖为以下代码<span lang="EN-US">: <span> </span><a name="iddle6621"></a><a name="iddle2357"></a><a name="d0e19458"></a><a name="d0e19457"></a><o:p></o:p></span></font>
				</span>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<font size="2">
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">
						<font size="2">
						</font>
				</span>
		</p>
		<div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)">
				<!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>-->
				<font size="2">
						<span style="COLOR: rgb(0,0,0)">1</span>
						<span style="COLOR: rgb(0,0,0)">   </span>
						<span style="COLOR: rgb(0,0,255)">public</span>
						<span style="COLOR: rgb(0,0,0)"> </span>
						<span style="COLOR: rgb(0,0,255)">static</span>
						<span style="COLOR: rgb(0,0,0)"> </span>
						<span style="COLOR: rgb(0,0,255)">void</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)"> main(String[] args) {<br /></span>
						<span style="COLOR: rgb(0,0,0)">2</span>
						<span style="COLOR: rgb(0,0,0)">      Display display </span>
						<span style="COLOR: rgb(0,0,0)">=</span>
						<span style="COLOR: rgb(0,0,0)"> </span>
						<span style="COLOR: rgb(0,0,255)">new</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)"> Display();<br /></span>
						<span style="COLOR: rgb(0,0,0)">3</span>
						<span style="COLOR: rgb(0,0,0)">      Shell shell </span>
						<span style="COLOR: rgb(0,0,0)">=</span>
						<span style="COLOR: rgb(0,0,0)"> </span>
						<span style="COLOR: rgb(0,0,255)">new</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)"> Shell(display);<br /></span>
						<span style="COLOR: rgb(0,0,0)">4</span>
						<span style="COLOR: rgb(0,0,0)">      shell.setText(</span>
						<span style="COLOR: rgb(0,0,0)">"</span>
						<span style="COLOR: rgb(0,0,0)">Hello World</span>
						<span style="COLOR: rgb(0,0,0)">"</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)">);<br /></span>
						<span style="COLOR: rgb(0,0,0)">5</span>
						<span style="COLOR: rgb(0,0,0)">      shell.setBounds(</span>
						<span style="COLOR: rgb(0,0,0)">100</span>
						<span style="COLOR: rgb(0,0,0)">, </span>
						<span style="COLOR: rgb(0,0,0)">100</span>
						<span style="COLOR: rgb(0,0,0)">, </span>
						<span style="COLOR: rgb(0,0,0)">200</span>
						<span style="COLOR: rgb(0,0,0)">, </span>
						<span style="COLOR: rgb(0,0,0)">50</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)">);<br /></span>
						<span style="COLOR: rgb(0,0,0)">6</span>
						<span style="COLOR: rgb(0,0,0)">      shell.setLayout(</span>
						<span style="COLOR: rgb(0,0,255)">new</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)"> FillLayout());<br /></span>
						<span style="COLOR: rgb(0,0,0)">7</span>
						<span style="COLOR: rgb(0,0,0)">      Label label </span>
						<span style="COLOR: rgb(0,0,0)">=</span>
						<span style="COLOR: rgb(0,0,0)"> </span>
						<span style="COLOR: rgb(0,0,255)">new</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)"> Label(shell, SWT.CENTER);<br /></span>
						<span style="COLOR: rgb(0,0,0)">8</span>
						<span style="COLOR: rgb(0,0,0)">      label.setText(</span>
						<span style="COLOR: rgb(0,0,0)">"</span>
						<span style="COLOR: rgb(0,0,0)">Hello World</span>
						<span style="COLOR: rgb(0,0,0)">"</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)">);<br /></span>
						<span style="COLOR: rgb(0,0,0)">9</span>
						<span style="COLOR: rgb(0,0,0)">      Color red </span>
						<span style="COLOR: rgb(0,0,0)">=</span>
						<span style="COLOR: rgb(0,0,0)"> </span>
						<span style="COLOR: rgb(0,0,255)">new</span>
						<span style="COLOR: rgb(0,0,0)"> Color(display, </span>
						<span style="COLOR: rgb(0,0,0)">255</span>
						<span style="COLOR: rgb(0,0,0)">, </span>
						<span style="COLOR: rgb(0,0,0)">0</span>
						<span style="COLOR: rgb(0,0,0)">, </span>
						<span style="COLOR: rgb(0,0,0)">0</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)">);<br /></span>
						<span style="COLOR: rgb(0,0,0)">10</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)">     label.setForeground(red);<br /></span>
						<span style="COLOR: rgb(0,0,0)">11</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)">     shell.open();<br /></span>
						<span style="COLOR: rgb(0,0,0)">12</span>
						<span style="COLOR: rgb(0,0,0)">     </span>
						<span style="COLOR: rgb(0,0,255)">while</span>
						<span style="COLOR: rgb(0,0,0)"> (</span>
						<span style="COLOR: rgb(0,0,0)">!</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)">shell.isDisposed()) {<br /></span>
						<span style="COLOR: rgb(0,0,0)">13</span>
						<span style="COLOR: rgb(0,0,0)">        </span>
						<span style="COLOR: rgb(0,0,255)">if</span>
						<span style="COLOR: rgb(0,0,0)"> (</span>
						<span style="COLOR: rgb(0,0,0)">!</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)">display.readAndDispatch()) display.sleep();<br /></span>
						<span style="COLOR: rgb(0,0,0)">14</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)">     }<br /></span>
						<span style="COLOR: rgb(0,0,0)">15</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)">     red.dispose();<br /></span>
						<span style="COLOR: rgb(0,0,0)">16</span>
				</font>
				<font size="2">
						<span style="COLOR: rgb(0,0,0)">     display.dispose();<br /></span>
						<span style="COLOR: rgb(0,0,0)">17</span>
				</font>
				<span style="COLOR: rgb(0,0,0)">
						<font size="2">  } <br /></font>
				</span>
		</div>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">
						<o:p>
								<font size="2">
								</font>
						</o:p>
				</span>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<font size="2">
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">注：<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">
						<font size="2">在覆盖了上述代码后<span lang="EN-US">, </span>选择菜单栏中的 </font>
						<a name="iddle6723">
						</a>
						<font size="2">
								<b>
										<span lang="EN-US">Source</span>
								</b>
								<span lang="EN-US">-&gt; <b>Organize Imports</b></span>命令<span lang="EN-US"> (</span>或者按<span lang="EN-US">Ctrl+Shift+O) </span>来把需要引用的<span lang="EN-US">SWT</span>包导入到<span lang="EN-US">HelloWorld.java</span>文件中 </font>
						<a name="d0e19487">
						</a>
						<font size="2">。<span lang="EN-US"><o:p></o:p></span></font>
				</span>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<a name="d0e19499">
				</a>
				<a name="d0e19498">
				</a>
				<a name="d0e19497">
				</a>
				<a name="d0e19496">
				</a>
				<a name="d0e19495">
				</a>
				<a name="d0e19494">
				</a>
				<a name="d0e19493">
				</a>
				<font size="2">
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">以下是对各行代码的详细解释：<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<font size="2">
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">第<span lang="EN-US">2</span>行：每个基于<span lang="EN-US">SWT</span>的应用程序都有一个<span lang="EN-US">Display</span>类的实例。用来将低层平台和<span lang="EN-US">SWT</span>进行链接。除了管理<span lang="EN-US">SWT</span>的事件循环，还能访问<span lang="EN-US">SWT</span>需要的平台资源。在<span lang="EN-US">16</span>行，<span lang="EN-US">display</span>实例将会提交给垃圾收集器。<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<font size="2">
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">第<span lang="EN-US">3</span>行：每一个窗口都有一个<span lang="EN-US">Shell</span>窗口框架，来与用户进行交互。<span lang="EN-US">Shell</span>像所有的<span lang="EN-US">windows</span>系统一样来处理动作行为，并作为窗口控件的放置场所。<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<font size="2">
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">第<span lang="EN-US">4</span>行： <span lang="EN-US">setText()</span>方法设置窗口的标题<span lang="EN-US">.<o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<font size="2">
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">第<span lang="EN-US">5</span>行： <span lang="EN-US">setBounds() </span>方法设置窗口的大小和放置的位置<span lang="EN-US">. </span>在这个例子中<span lang="EN-US">, </span>设置窗口为<span lang="EN-US">200</span>个像素宽，<span lang="EN-US">50</span>个像素高，并放在离屏幕的左上角<span lang="EN-US">100x100</span>像素的位置上。<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">
						<font size="2">第<span lang="EN-US">6</span>行： <span lang="EN-US">setLayout()</span>方法 设置窗口框架的布局<span lang="EN-US">. FillLayout</span>，充满式布局管理器，使得组件大小会尽量的充满整个容器<span lang="EN-US">.SWT</span>的布局管理器会在以后详细介绍。 <span lang="EN-US"><o:p></o:p></span></font>
				</span>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<font size="2">
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">第<span lang="EN-US">7</span>行：在<span lang="EN-US">shell</span>上新建一个简单的<span lang="EN-US">label</span>组件并居中显示<span lang="EN-US">label</span>的文本内容。<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<font size="2">
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">第<span lang="EN-US">8</span>行： <span lang="EN-US">setText() </span>方法 设置<span lang="EN-US">label</span>的文本内容。<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<font size="2">
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">第<span lang="EN-US">9</span>行：创建一个红色的颜色类的实例。你也可以使用以下语句获得系统红色的实例：<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-INDENT: 60pt; TEXT-ALIGN: left" align="left">
				<font size="2">
						<span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">Color red = display.getSystemColor(SWT.COLOR_RED);<o:p></o:p></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<font size="2">
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">第<span lang="EN-US">10</span>行： <span lang="EN-US">setForeground() </span>方法 <span> </span>设置<span lang="EN-US">label</span>的前景色<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<font size="2">
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">第<span lang="EN-US">11</span>行：到目前为止，窗口框架还是不可见的。通过<span lang="EN-US">open()</span>方法使得窗口可见。<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<font size="2">
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">第<span lang="EN-US">12</span>行： <span lang="EN-US">while</span>语句循环检测窗口有没有关闭。<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">
						<font size="2">第<span lang="EN-US">13</span>行：<span lang="EN-US">display </span>控制事件的循环<span lang="EN-US">. readAndDispatch() </span>方法从平台的事件队列中读取事件，并分配他们到合适的处理程序<span lang="EN-US">(</span>接收者<span lang="EN-US">)</span>。只要队列中一直有事件可以处理，这个方法一直返回<span lang="EN-US">true</span>，当事件队列为空时，则返回<span lang="EN-US">false(</span>因此允许用户界面<span lang="EN-US">UI</span>线程出于<span lang="EN-US">sleep</span>状态直到事件队列不为空<span lang="EN-US">)</span>。 <span lang="EN-US"><o:p></o:p></span></font>
				</span>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<font size="2">
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">第<span lang="EN-US">15,16</span>行：当循环检测到窗口被关闭时，需要将<span lang="EN-US">color</span>，<span lang="EN-US">display</span>和一些相关联的平台资源释放。注意到系统颜色实例<span lang="EN-US">(colors)</span>将会被提交释放。<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN-LEFT: 21pt; TEXT-INDENT: -21pt; TEXT-ALIGN: left" align="left">
				<font size="2">
						<span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">
								<span>二、<span style="FONT: 7pt 'Times New Roman'; font-size-adjust: none; font-stretch: normal">            </span></span>
						</span>
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">运行这个例子<span lang="EN-US"><o:p></o:p></span></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-ALIGN: left" align="left">
				<font size="2">
						<span style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">通常情况下，为了启动一个<span lang="EN-US">java</span>应用程序，会使用<b><span lang="EN-US">Run As -</span>〉</b></span>
						<span class="docemphstrong">
								<b>
										<span lang="EN-US">Java Application</span>
								</b>
						</span>
						<span class="docemphstrong">
								<span style="FONT-FAMILY: 宋体">命令。在这里，如此运行将会抛出</span>
						</span>
						<b>
								<span lang="EN-US">UnsatisfiedLinkError</span>
						</b>
						<span style="FONT-FAMILY: 宋体">异常，说明没有找到</span>
						<span lang="EN-US">SWT</span>
						<span style="FONT-FAMILY: 宋体">的本地库。如果运行</span>
						<span class="docemphstrong">
								<b>
										<span lang="EN-US">Run As &gt; SWT Application</span>
								</b>
								<span lang="EN-US">
								</span>
						</span>
						<span class="docemphstrong">
								<span style="FONT-FAMILY: 宋体">命令，将会弹出</span>
								<span lang="EN-US">SWT</span>
						</span>
						<span class="docemphstrong">
								<span style="FONT-FAMILY: 宋体">启动配置窗口，见图</span>
								<span lang="EN-US">2</span>
						</span>
						<span class="docemphstrong">
								<span style="FONT-FAMILY: 宋体">，在图</span>
								<span lang="EN-US">2</span>
						</span>
						<span class="docemphstrong">
								<span style="FONT-FAMILY: 宋体">中可以点击</span>
								<b>
										<span lang="EN-US">run</span>
								</b>
						</span>
						<span class="docemphstrong">
								<span style="FONT-FAMILY: 宋体">按钮。 </span>
						</span>
						<span lang="EN-US" style="FONT-SIZE: 12pt; FONT-FAMILY: 宋体">
								<o:p>
								</o:p>
						</span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-INDENT: 21pt">
				<font size="2">
						<span lang="EN-US"> <img height="337" alt="{3717602A-4D02-4E2D-A913-A6BC4E1289A8}.BMP" src="http://www.blogjava.net/images/blogjava_net/cpenet/%7B3717602A-4D02-4E2D-A913-A6BC4E1289A8%7D.BMP" width="504" border="0" /></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-INDENT: 21pt">
				<font size="2">
						<span lang="EN-US">
								<span>                                </span>
						</span>
						<span style="FONT-FAMILY: 宋体">图</span>
						<span lang="EN-US">2</span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-INDENT: 21pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体">点击</span>
						<b>
								<span lang="EN-US">run</span>
						</b>
						<span style="FONT-FAMILY: 宋体">，运行结果图</span>
						<span lang="EN-US">3</span>
						<span style="FONT-FAMILY: 宋体">。</span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-INDENT: 21pt">
				<font size="2">
						<span lang="EN-US"> <img height="53" alt="{978DFCF8-658E-40EC-80D4-3DD5D8FACF1F}.BMP" src="http://www.blogjava.net/images/blogjava_net/cpenet/%7B978DFCF8-658E-40EC-80D4-3DD5D8FACF1F%7D.BMP" width="203" border="0" /></span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-INDENT: 21pt">
				<font size="2">
						<span lang="EN-US">
								<span>          </span>
						</span>
						<span style="FONT-FAMILY: 宋体">图</span>
						<span lang="EN-US">3</span>
				</font>
		</p>
		<p class="MsoNormal" style="TEXT-INDENT: 21pt">
				<span lang="EN-US">
						<font size="2">(以后继续) <br /></font>
				</span>
		</p>
<img src ="http://www.blogjava.net/cpenet/aggbug/56407.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cpenet/" target="_blank">燕然</a> 2006-07-03 20:09 <a href="http://www.blogjava.net/cpenet/archive/2006/07/03/56407.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>org.eclipse.ui 包</title><link>http://www.blogjava.net/cpenet/archive/2006/06/30/IWorkbenchWindow.html</link><dc:creator>燕然</dc:creator><author>燕然</author><pubDate>Fri, 30 Jun 2006 12:10:00 GMT</pubDate><guid>http://www.blogjava.net/cpenet/archive/2006/06/30/IWorkbenchWindow.html</guid><wfw:comment>http://www.blogjava.net/cpenet/comments/56025.html</wfw:comment><comments>http://www.blogjava.net/cpenet/archive/2006/06/30/IWorkbenchWindow.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/cpenet/comments/commentRss/56025.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cpenet/services/trackbacks/56025.html</trackback:ping><description><![CDATA[
		<font size="2">org.eclipse.ui包是应用程序界面的包, Eclipse的平台的界面也是使用了这个包.<br />包中有接口IWorkbenchWindow,API中的说明<br /></font>
		<p>
				<font size="2">A workbench window is a top level window in a workbench. Visually, a workbench window has a menubar, a toolbar, a status bar, and a main area for displaying a single page consisting of a collection of views and editors. </font>
		</p>
		<p>
				<font size="2">Each workbench window has a collection of 0 or more pages; the active page is the one that is being presented to the end user; at most one page is active in a window at a time. </font>
		</p>
		<p>
				<font size="2">This interface is not intended to be implemented by clients.</font>
		</p>
		<p>
				<font size="2">一个工作台窗口是一个工作台的顶层窗口.从视觉上看,一个工作台窗口拥有一个菜单栏,工具栏,状态栏和一个主区域,用来显示包括显示和编辑的一个页面.</font>
		</p>
		<p>
				<font size="2">每个工作台窗口有0个或者更多的页面.活动的页面是一种显示给当前使用者的页面.大多数情况下,在一个时刻只有一个页面处于活动状态.</font>
		</p>
		<p>
				<font size="2">这个接口不打算由用户来实现.</font>
		</p>
		<p>
				<b>
						<font size="2">(to more)</font>
				</b>
				<br />
		</p>
<img src ="http://www.blogjava.net/cpenet/aggbug/56025.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cpenet/" target="_blank">燕然</a> 2006-06-30 20:10 <a href="http://www.blogjava.net/cpenet/archive/2006/06/30/IWorkbenchWindow.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Rich Client Tutorial Part 1（翻译）</title><link>http://www.blogjava.net/cpenet/archive/2006/06/30/56010.html</link><dc:creator>燕然</dc:creator><author>燕然</author><pubDate>Fri, 30 Jun 2006 10:27:00 GMT</pubDate><guid>http://www.blogjava.net/cpenet/archive/2006/06/30/56010.html</guid><wfw:comment>http://www.blogjava.net/cpenet/comments/56010.html</wfw:comment><comments>http://www.blogjava.net/cpenet/archive/2006/06/30/56010.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/cpenet/comments/commentRss/56010.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cpenet/services/trackbacks/56010.html</trackback:ping><description><![CDATA[
		<div>
				<font size="2">Rich Client Tutorial是Eclipse官方网站的RCP开发指南。原文地址为：</font>
				<a href="http://www.eclipse.org/articles/Article-RCP-1/tutorial1.html">
						<font size="2">http://www.eclipse.org/articles/Article-RCP-1/tutorial1.html</font>
				</a>
		</div>
		<div>
				<font size="2">
				</font>
		</div>
		<div>
				<font size="2">第一次翻译，有错误，欢迎指正。</font>
		</div>
		<div>
				<font size="2">
				</font>
		</div>
		<div>
				<font size="2">
				</font>
		</div>
		<p>
				<span lang="EN-US" style="FONT-FAMILY: Verdana">
						<font size="2">
								<font color="#000000">Rich Client Tutorial Part 1</font>
						</font>
				</span>
		</p>
		<p>
				<span lang="EN-US" style="FONT-FAMILY: Verdana">
						<font size="2">
								<font color="#000000">The Rich Client Platform (RCP) is an exciting new way to build Java applications that can compete with native applications on any platform. This tutorial is designed to get you started building RCP applications quickly. It has been updated for Eclipse 3.1.2</font>
						</font>
				</span>
		</p>
		<div>
				<font color="#000000">
						<font size="2">
								<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体">富客户端平台（</span>
								<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Verdana">RCP</span>
								<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体">）是一个令人兴奋的创建</span>
								<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Verdana">java</span>
								<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体">应用程序的新方式，她可以与任何平台下的本地应用程序相媲美。这份指南目的在于让你快速的构建</span>
								<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Verdana">rcp</span>
								<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体">应用程序。本指南已更新，适用于</span>
								<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Verdana">Eclipse 3.1.2</span>
								<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体">。</span>
						</font>
				</font>
		</div>
		<font color="#000000">
				<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体">
						<h2>
								<font size="2">
										<span lang="EN-US" style="FONT-SIZE: 10.5pt; LINE-HEIGHT: 173%; FONT-FAMILY: Verdana">Introduction</span>
								</font>
						</h2>
						<p>
								<font size="2">
										<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Verdana">Try this experiment: Show Eclipse to some friends or co-workers who haven't seen it before and ask them to guess what language it is written in. Chances are, they'll guess VB, C++, or C#, because those languages are used most often for high quality client side applications. Then watch the look on their faces when you tell them it was created in Java, especially if they are Java programmers.</span>
								</font>
						</p>
						<p>
								<font size="2">
										<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Verdana">Because of its unique open source license, you can use the technologies that went into Eclipse to create your own commercial quality programs. Before version 3.0, this was possible but difficult, especially when you wanted to heavily customize the menus, layouts, and other user interface elements. That was because the "IDE-ness" of Eclipse was hard-wired into it. Version 3.0 introduced the Rich Client Platform (RCP), which is basically a refactoring of the fundamental parts of Eclipse's UI, allowing it to be used for non-IDE applications. Version 3.1 updated RCP with new capabilities, and, most importantly, new tooling support to make it easier to create than before.</span>
								</font>
						</p>
						<p>
								<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Verdana">
										<font size="2">If you want to cut to the chase and look at the code for this part you can find it in the </font>
										<a href="http://www.eclipse.org/articles/Article-RCP-1/part1.zip">
												<u>
														<font color="#0000ff" size="2">accompanying zip file</font>
												</u>
										</a>
										<font size="2">. Otherwise, let's take a look at how to construct an RCP application.</font>
								</span>
								<font size="2">
								</font>
						</p>
						<p>
								<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Verdana">
										<font size="2">
										</font>
								</span>
						</p>
						<p>
								<font size="2">
										<span style="FONT-FAMILY: 宋体">
												<strong>引言</strong>
										</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">
										</span>
								</font>
						</p>
						<p>
								<font size="2">
										<span style="FONT-FAMILY: 宋体">尝试做这个实验：把</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">Eclipse</span>
										<span style="FONT-FAMILY: 宋体">展示给你的那些以前没见过</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">Eclipse</span>
										<span style="FONT-FAMILY: 宋体">的朋友或合作伙伴，让他们猜猜这是用何种语言编写的。很有可能，他们会说是</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">VB</span>
										<span style="FONT-FAMILY: 宋体">，</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">C++</span>
										<span style="FONT-FAMILY: 宋体">或者</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">C#</span>
										<span style="FONT-FAMILY: 宋体">，因为这些语言经常被用来作为高质量客户端方面的应用程序。当你告诉他们是用</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">java</span>
										<span style="FONT-FAMILY: 宋体">编写时，察看他们脸上的表情，尤其当他们是</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">java</span>
										<span style="FONT-FAMILY: 宋体">程序员的话。</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">
										</span>
								</font>
						</p>
						<p>
								<font size="2">
										<span style="FONT-FAMILY: 宋体">因为</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">Eclipse</span>
										<span style="FONT-FAMILY: 宋体">是唯一</span>
										<span style="FONT-FAMILY: 宋体">开放源代码许可的，你可以用</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">Eclipse</span>
										<span style="FONT-FAMILY: 宋体">这个技术来创建你自己商业质量的程序。在</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">3.0</span>
										<span style="FONT-FAMILY: 宋体">版本以前，这是可能的，但也是困难的，尤其当你想要订制菜单，多层和其他用户界面元素时。那是因为很难接触到</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">Eclipse</span>
										<span style="FONT-FAMILY: 宋体">的</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">IDE</span>
										<span style="FONT-FAMILY: 宋体">核心。</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">3.0</span>
										<span style="FONT-FAMILY: 宋体">版本的</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">Eclipse</span>
										<span style="FONT-FAMILY: 宋体">引入了富客户端编程（</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">RCP</span>
										<span style="FONT-FAMILY: 宋体">），这基本上是</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">Eclipse UI</span>
										<span style="FONT-FAMILY: 宋体">的重新构建，也就允许</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">Eclipse UI </span>
										<span style="FONT-FAMILY: 宋体">被应用到非</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">Eclipse IDE</span>
										<span style="FONT-FAMILY: 宋体">的应用程序中。</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">3.1</span>
										<span style="FONT-FAMILY: 宋体">版本的</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">Eclipse</span>
										<span style="FONT-FAMILY: 宋体">用新特性升级了</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">RCP</span>
										<span style="FONT-FAMILY: 宋体">，最重要的是，新的工具使的创建</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">RCP </span>
										<span style="FONT-FAMILY: 宋体">应用程序比以前更加容易。</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">
										</span>
								</font>
						</p>
						<p>
								<font size="2">
										<span style="FONT-FAMILY: 宋体">如果你想要研究</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">Rich Client Tutorial Part 1</span>
										<span style="FONT-FAMILY: 宋体">的代码，你可以到</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">
												<a href="http://www.eclipse.org/articles/Article-RCP-1/part1.zip">
														<u>
																<font color="#0000ff">accompanying zip file</font>
														</u>
												</a>
										</span>
										<span style="FONT-FAMILY: 宋体">下载。另外，让我们一步步来看看如何创建一个</span>
										<span lang="EN-US" style="FONT-FAMILY: Verdana">RCP</span>
										<span style="FONT-FAMILY: 宋体">应用程序。</span>
								</font>
						</p>
						<span style="FONT-FAMILY: 宋体">
								<h2>
										<font size="2">
												<span lang="EN-US" style="FONT-SIZE: 10.5pt; LINE-HEIGHT: 173%; FONT-FAMILY: Verdana">Getting started</span>
										</font>
								</h2>
								<p>
										<font size="2">
												<span style="FONT-FAMILY: 宋体">开始</span>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">
												</span>
										</font>
								</p>
								<p>
										<font size="2">
												<span lang="EN-US" style="FONT-SIZE: 10.5pt; FONT-FAMILY: Verdana">RCP applications are based on the familiar Eclipse plug-in architecture, (if it's not familiar to you, see the references section). Therefore, you'll need to create a plug-in to be your main program. Eclipse's Plug-in Development Environment (PDE) provides a number of wizards and editors that take some of the drudgery out of the process. PDE is included with the Eclipse SDK download so that is the package you should be using. Here are the steps you should follow to get started.</span>
										</font>
								</p>
								<p>
										<font size="2">
												<span lang="EN-US" style="FONT-FAMILY: Verdana">RCP</span>
												<span style="FONT-FAMILY: 宋体">应用程序基于熟悉的</span>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">Eclipse</span>
												<span style="FONT-FAMILY: 宋体">插件机制，（如果你不熟悉，请查看参考书目部分）。因此，你要创建一个插件来作为你的主程序。</span>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">Eclipse</span>
												<span style="FONT-FAMILY: 宋体">的插件开发环境（</span>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">PDE</span>
												<span style="FONT-FAMILY: 宋体">）提供了大量的控件和编辑器来使得开发过程脱离苦海。</span>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">PDE</span>
												<span style="FONT-FAMILY: 宋体">包括在了</span>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">Eclipse SDK</span>
												<span style="FONT-FAMILY: 宋体">，所以</span>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">PDE</span>
												<span style="FONT-FAMILY: 宋体">开发包你可以直接使用。以下是开始开发的步骤：</span>
												<span lang="EN-US" style="FONT-FAMILY: Verdana">
												</span>
										</font>
								</p>
								<p>
										<span lang="EN-US">
												<font size="2">
														<font face="Times New Roman">First, bring up Eclipse and select <b>File &gt; New &gt; Project</b>, then expand <b>Plug-in Development</b> and double-click <b>Plug-in Project</b> to bring up the Plug-in Project wizard. On the subsequent pages, enter a Project name such as <b>org.eclipse.ui.tutorials.rcp.part1</b>, indicate you want a Java project, select the version of Eclipse you're targeting (at least 3.1), and enable the option to Create an OSGi bundle manifest. Then click <b>Next &gt;</b>.</font>
												</font>
										</span>
								</p>
								<p>
										<font size="2">
												<span style="FONT-FAMILY: 宋体">首先，启动</span>
												<span lang="EN-US">
														<font face="Times New Roman">Eclipse</font>
												</span>
												<span>，选择<strong><font face="Times New Roman">File &gt; New &gt; Project</font>。</strong>接下来选中</span>
												<span>
														<strong>
																<font face="Times New Roman">Plug-in Development</font>，</strong>双击来打开插件工程向导。在弹出的页面中，键入工程名（例如：</span>
												<span>
														<font face="Times New Roman">org.eclipse.ui.tutorials.rcp.part1</font>），指明你要一个</span>
												<span>
														<font face="Times New Roman">java</font>工程，选择你想创建适用的</span>
												<span>
														<font face="Times New Roman">Eclise</font>的版本，并选中使用</span>
												<span>
														<font face="Times New Roman">OSGI</font>包。接下来点击</span>
												<span>
														<font face="Times New Roman">
																<strong>Next&gt;</strong>
														</font>。</span>
										</font>
								</p>
								<p align="left">
										<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
												<b>note：</b>Beginning in Eclipse 3.1 you will get best results by using the OSGi bundle manifest. In contrast to previous versions, this is now the default.</span>
										<font size="2">
										</font>
								</p>
								<p align="left">
										<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">In the next page of the Wizard you can change the Plug-in ID and other parameters. Of particular importance is the question, "Would you like to create a rich client application?". Select <b>Yes</b>. The generated plug-in class is optional but for this example just leave all the other options at their default values. Click <b>Next &gt;</b> to continue.</span>
										<font size="2">
										</font>
								</p>
								<p>
										<font size="2">
												<span style="FONT-FAMILY: 宋体">注：</span>
												<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">通过使用</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Eclipse 3.1</span>
												<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">的</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">OSGI</span>
												<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">包，你会获得很好的结果。与以前的版本相比，</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">OSGi</span>
												<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">现在是默认的了。</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
												</span>
										</font>
								</p>
								<p>
										<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">在下一页向导中，你可以更改插件的</span>
										<font size="2">
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">ID</span>
												<span>号和其他参数。尤其要关注一个问题：“你想要创建一个富客户端的应用程序吗？”，选择“是”。生成的插件类是可选的，但对于这个例子，一切其他的可选项都设为默认值。单击<strong>Next &gt;</strong>到下一页<strong>。</strong></span>
										</font>
								</p>
								<p>
										<font color="#000000">
												<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体">
														<span style="FONT-FAMILY: 宋体">
																<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
																		<b>note：</b>
																</span>
														</span>
												</span>
										</font>
										<span lang="EN-US">
												<font size="2">
														<font face="Times New Roman">If you get a dialog asking if Eclipse can switch to the Plug-in Development Perspective click Remember my decision and select Yes (this is optional).</font>
												</font>
										</span>
								</p>
								<p>
										<span lang="EN-US">
												<span>
														<font face="Times New Roman">
														</font>
												</span>
										</span>
										<font size="2">
												<span style="FONT-FAMILY: 宋体">注：如果你得到一个对话框，询问</span>
												<span lang="EN-US">
														<font face="Times New Roman">Eclipse</font>
												</span>
												<span style="FONT-FAMILY: 宋体">是否切换到插件开发透视图。这时单击记住我的选择并选择“是”（这是可选的）。</span>
										</font>
								</p>
								<p align="left">
										<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Starting with Eclipse 3.1, several templates have been provided to make creating an RCP application a breeze. We'll use the simplest one available and see how it works. Make sure the option to Create a plug-in using one of the templates is enabled, then select the Hello RCP template. This is RCP's equivalent of "Hello, world". Click <b>Finish</b> to accept all the defaults and generate the project (see Figure 1). Eclipse will open the Plug-in Manifest Editor. The Plug-in Manifest editor puts a friendly face on the various configuration files that control your RCP application.</span>
										<font size="2">
										</font>
								</p>
								<p>
										<font size="2">
												<span style="FONT-FAMILY: 宋体">从</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Eclipse 3.1</span>
												<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">开始，提供了几个模板使得创建</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">RCP</span>
												<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">应用程序相当容易。我们使用最简单的一个模板来观察这是如何工作的。确保创建一个插件使用模板之一是允许的，接着选择“</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Hello RCP</span>
												<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">”模板。这是</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">RCP</span>
												<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">应用程序中的“</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Hello, world</span>
												<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">”。选择“完成”来创建工程（见图一）。</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Eclipse</span>
												<span style="FONT-SIZE: 10pt; FONT-FAMILY: 宋体">将会打开插件编辑器。插件编辑器提供了友好的界面，拥有多样的配置文件来控制你的ＲＣＰ应用程序。</span>
												<span lang="EN-US" style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">
												</span>
										</font>
								</p>
						</span>
						<span lang="EN-US" style="FONT-FAMILY: Verdana">
						</span>
						<p>
								<span lang="EN-US">
										<font face="Times New Roman">
												<br />
												<font size="2">
												</font>
										</font>
								</span>
						</p>
						<p>
								<font size="2">
										<img src="http://tk.files.storage.msn.com/x1pC47KWjv0VYlVJoXflCycqsf3vxSwGOKdrfc_VaoARtC3vC-5mkIITI1X0WvU5pIjhRv7uDNzMNyLqf90JI-XqAAwAuN-q1t2ixMa5GSL5VuUwEfLGbtb9w6svbm4WKMeTuTgTOCr1mw" />
								</font>
								<span style="FONT-FAMILY: 宋体">
										<br />
								</span>
						</p>
						<p>
								<font color="#000000">
										<span style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体">
												<span lang="EN-US">
														<font size="2">
																<font face="Times New Roman">Figure 1. The Hello World RCP project was created by a PDE wizard.</font>
														</font>
												</span>
										</span>
								</font>
						</p>
						<p>
								<font size="2">
										<span style="FONT-FAMILY: 宋体">图一，ＰＤＥ向导创建的Ｈｅｌｌｏ　Ｗｏｒｌｄ工程</span>
								</font>
						</p>
						<p>
								<font size="2">
										<span style="FONT-FAMILY: 宋体">(未完，待续)</span>
								</font>
						</p>
				</span>
		</font>
<img src ="http://www.blogjava.net/cpenet/aggbug/56010.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cpenet/" target="_blank">燕然</a> 2006-06-30 18:27 <a href="http://www.blogjava.net/cpenet/archive/2006/06/30/56010.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>学习rcp 感觉好烦啊</title><link>http://www.blogjava.net/cpenet/archive/2006/06/30/56009.html</link><dc:creator>燕然</dc:creator><author>燕然</author><pubDate>Fri, 30 Jun 2006 10:16:00 GMT</pubDate><guid>http://www.blogjava.net/cpenet/archive/2006/06/30/56009.html</guid><wfw:comment>http://www.blogjava.net/cpenet/comments/56009.html</wfw:comment><comments>http://www.blogjava.net/cpenet/archive/2006/06/30/56009.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/cpenet/comments/commentRss/56009.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/cpenet/services/trackbacks/56009.html</trackback:ping><description><![CDATA[这个RCP的开发怎么感觉转来转去，转晕了。。唉，对eclipse的开发api又很不熟悉，感觉无从下手。<img src ="http://www.blogjava.net/cpenet/aggbug/56009.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/cpenet/" target="_blank">燕然</a> 2006-06-30 18:16 <a href="http://www.blogjava.net/cpenet/archive/2006/06/30/56009.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>