﻿<?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-BeanSoft's Java Blog-随笔分类-SWT/JFACE/RCP</title><link>http://www.blogjava.net/beansoft/category/20278.html</link><description>MyEclipse 教程, Java EE 5, JSPWiki, Spring, Struts, Hibernate, JPA, SWT, Swing, AJAX, JavaScript, Netbeans</description><language>zh-cn</language><lastBuildDate>Thu, 10 Jan 2008 15:59:57 GMT</lastBuildDate><pubDate>Thu, 10 Jan 2008 15:59:57 GMT</pubDate><ttl>60</ttl><item><title>可以在多普达微软 Pocket PC Windows Mobile 5 手机上运行的eswt程序包</title><link>http://www.blogjava.net/beansoft/archive/2008/01/10/174248.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Thu, 10 Jan 2008 04:51:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2008/01/10/174248.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/174248.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2008/01/10/174248.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/174248.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/174248.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 手机版 SWT 软件包和源代码&nbsp;&nbsp;<a href='http://www.blogjava.net/beansoft/archive/2008/01/10/174248.html'>阅读全文</a><img src ="http://www.blogjava.net/beansoft/aggbug/174248.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2008-01-10 12:51 <a href="http://www.blogjava.net/beansoft/archive/2008/01/10/174248.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>BlogJava 备份文章阅读器:增加日期范围增量备份功能</title><link>http://www.blogjava.net/beansoft/archive/2008/01/08/173714.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Tue, 08 Jan 2008 09:53:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2008/01/08/173714.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/173714.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2008/01/08/173714.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/173714.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/173714.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.blogjava.net/beansoft/archive/2008/01/08/173714.html'>阅读全文</a><img src ="http://www.blogjava.net/beansoft/aggbug/173714.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2008-01-08 17:53 <a href="http://www.blogjava.net/beansoft/archive/2008/01/08/173714.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SWT Ribbon Control 主页及下载地址, 精彩截屏</title><link>http://www.blogjava.net/beansoft/archive/2007/10/07/150887.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Sun, 07 Oct 2007 11:42:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/10/07/150887.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/150887.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/10/07/150887.html#Feedback</comments><slash:comments>8</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/150887.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/150887.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: http://hexapixel.com/projects/								http://hexapixel.com/ribbon/				下载地址: download the jar and the source		源码包里面的 com.hexapixel.widgets.ribbon.RibbonTester 展示了如何使用这个组件.		作者提示道: 可能有很多 b...&nbsp;&nbsp;<a href='http://www.blogjava.net/beansoft/archive/2007/10/07/150887.html'>阅读全文</a><img src ="http://www.blogjava.net/beansoft/aggbug/150887.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-10-07 19:42 <a href="http://www.blogjava.net/beansoft/archive/2007/10/07/150887.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>下载并使用 Windows Mobile 5.0 模拟器(图文,视频) SWT on 手机</title><link>http://www.blogjava.net/beansoft/archive/2007/09/13/144821.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Thu, 13 Sep 2007 05:05:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/09/13/144821.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/144821.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/09/13/144821.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/144821.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/144821.html</trackback:ping><description><![CDATA[<p>首先是下载地址: Standalone Device Emulator 1.0 with Windows Mobile OS Images <a title="https://www.microsoft.com/downloads/details.aspx?FamilyID=c62d54a5-183a-4a1e-a7e2-cc500ed1f19a&amp;displaylang=en" href="https://www.microsoft.com/downloads/details.aspx?FamilyID=c62d54a5-183a-4a1e-a7e2-cc500ed1f19a&amp;displaylang=en">https://www.microsoft.com/downloads/details.aspx?FamilyID=c62d54a5-183a-4a1e-a7e2-cc500ed1f19a&amp;displaylang=en</a></p> <p>需要下载并安装页面所显示的两个包:&nbsp;<basefont face="Verdana, Arial, Helvetica">  <table dir="ltr" cellspacing="0" cellpadding="0" width="100%" border="0" unselectable="on"> <tbody> <tr valign="top"> <td dir="ltr" width="100%"> <div class="pageMargin" id="details"> <h4>Files in This Download</h4> <div class="downloadInfo">The links in this section correspond to separate files available in this download. Download the files most appropriate for you.</div> <table id="multiFileList" cellspacing="0" cellpadding="3" border="0" unselectable="on"> <tbody> <tr bgcolor="#dddddd"> <th id="multiFileNameCol">File Name:</th> <th id="sizeCol">File Size</th> <th class="buttonCell">&nbsp;</th></tr> <tr> <td> <p>efp.msi</p></td> <td> <p>57.0 MB</p></td> <td class="buttonCell"><button>Download</button><noscript><a href="info.aspx?na=46&amp;p=1&amp;SrcDisplayLang=en&amp;SrcCategoryId=&amp;SrcFamilyId=c62d54a5-183a-4a1e-a7e2-cc500ed1f19a&amp;u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2fc%2fb%2fb%2fcbb8bc58-07b9-46bb-86ba-d12bb0d9b1d9%2fefp.msi&amp;oRef=http%3a%2f%2fwww.google.cn%2fsearch%3fcomplete%3d1%26hl%3dzh-CN%26newwindow%3d1%26q%3dWindows%2bDevice%2bEmulator%26meta%3d%26aq%3dnull">Download</a></noscript></td></tr> <tr bgcolor="#f1f1f1"> <td> <p>V1Emulator.zip</p></td> <td> <p>867 KB</p></td> <td class="buttonCell"><button>Download</button><noscript><a href="info.aspx?na=46&amp;p=2&amp;SrcDisplayLang=en&amp;SrcCategoryId=&amp;SrcFamilyId=c62d54a5-183a-4a1e-a7e2-cc500ed1f19a&amp;u=http%3a%2f%2fdownload.microsoft.com%2fdownload%2fc%2fb%2fb%2fcbb8bc58-07b9-46bb-86ba-d12bb0d9b1d9%2fV1Emulator.zip&amp;oRef=http%3a%2f%2fwww.google.cn%2fsearch%3fcomplete%3d1%26hl%3dzh-CN%26newwindow%3d1%26q%3dWindows%2bDevice%2bEmulator%26meta%3d%26aq%3dnull">Download</a></noscript></td></tr></tbody></table></div></td></tr></tbody></table></basefont></p> <p>&nbsp;第一个包是 Windows Mobile 5.0 的 Pocket PC 和 Smartphone 的模拟器文件, 第二个是模拟器. 安装的时候先安装 V1Emulator.zip, 然后再安装 efp.msi.&nbsp; 注意似乎 PPC 2003 并不能被这个模拟器支持, 要装对应的 SDK, 只有这个是不需要单独安装 VS Studio 和 SDK 的.</p> <p>安装完毕后可以在开始菜单项里看到如下的程序组:</p> <p>Windows Mobile 5.0 MSFP Emulator Images</p> <blockquote> <p><a href="http://www.blogjava.net/images/blogjava_net/beansoft/WindowsLiveWriter/WindowsMobile5.0_892C/ppc1.png" atomicselection="true"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="168" alt="ppc1" src="http://www.blogjava.net/images/blogjava_net/beansoft/WindowsLiveWriter/WindowsMobile5.0_892C/ppc1_thumb.png" width="576" border="0"></a>&nbsp;</p></blockquote> <p>要启动 Pocket PC, 可以选择 Coldboot(干净的启动镜像) 和 Savestate(保存过的镜像状态). 这里我选择 Coldboot 来展示如何在 PC 和 模拟器之间共享文件, 这样你就可以安装程序并进行测试了. 注意的是这些 Mobile 版 Windows 5.0 都是英文版的.</p> <p>点击 PocketPC - Coldboot 来启动模拟器. 启动后点选模拟器窗口的菜单项 文件 -&gt; 配置 ..., 选择共享文件夹右侧的浏览按钮来选择PC的一个目录作为和模拟器共享的外部存储器(Storage Card).</p> <p><a href="http://www.blogjava.net/images/blogjava_net/beansoft/WindowsLiveWriter/WindowsMobile5.0_892C/image.png" atomicselection="true"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="442" alt="image" src="http://www.blogjava.net/images/blogjava_net/beansoft/WindowsLiveWriter/WindowsMobile5.0_892C/image_thumb.png" width="702" border="0"></a> </p> <p>然后选择PPC的 Start -&gt; Programs 来打开程序快捷键, </p> <p><a href="http://www.blogjava.net/images/blogjava_net/beansoft/WindowsLiveWriter/WindowsMobile5.0_892C/ppc3.png" atomicselection="true"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="458" alt="ppc3" src="http://www.blogjava.net/images/blogjava_net/beansoft/WindowsLiveWriter/WindowsMobile5.0_892C/ppc3_thumb.png" width="297" border="0"></a>&nbsp;</p> <p>接着选择 File Explorer 来启动资源管理器.</p> <p><a href="http://www.blogjava.net/images/blogjava_net/beansoft/WindowsLiveWriter/WindowsMobile5.0_892C/ppc4.png" atomicselection="true"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="324" alt="ppc4" src="http://www.blogjava.net/images/blogjava_net/beansoft/WindowsLiveWriter/WindowsMobile5.0_892C/ppc4_thumb.png" width="242" border="0"></a> </p> <p>选择 Storage Card, 就可以看到 PC 共享目录里的文件了, 你可以安装程序(PPC 的安装程序一般都是 CAB 格式), 复制文件等等. 也可以启动先前开发的 eswt 程序.</p> <p><a href="http://www.blogjava.net/images/blogjava_net/beansoft/WindowsLiveWriter/WindowsMobile5.0_892C/ppc5.png" atomicselection="true"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="322" alt="ppc5" src="http://www.blogjava.net/images/blogjava_net/beansoft/WindowsLiveWriter/WindowsMobile5.0_892C/ppc5_thumb.png" width="244" border="0"></a> </p> <p>&nbsp;</p> <p>本人已经制作了一个可以运行在 PPC 模拟器和手机上(WM5.0)的eswt程序包, 复制到/j9p即可运行, 有兴趣的欢迎索取压缩包.</p> <p><a href="http://www.blogjava.net/images/blogjava_net/beansoft/WindowsLiveWriter/WindowsMobile5.0_892C/ppc7.png" atomicselection="true"><img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="324" alt="ppc7" src="http://www.blogjava.net/images/blogjava_net/beansoft/WindowsLiveWriter/WindowsMobile5.0_892C/ppc7_thumb.png" width="244" border="0"></a> </p> <p>下面show一下操作 PPC 模拟器的视频:</p> <p><a title="http://download.gro.clinux.org/beansoft/ppc_emulator.swf" href="http://download.gro.clinux.org/beansoft/ppc_emulator.swf">http://download.gro.clinux.org/beansoft/ppc_emulator.swf</a>&nbsp;464KB</p> <p><embed pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" src="http://download.gro.clinux.org/beansoft/ppc_emulator.swf" width="356" height="576" type="application/x-shockwave-flash" bgcolor="#FFFFFF" quality="high"></p> <p>手机开发 RCP/SWT 程序的项目首页在: embedded Rich Client Platform (eRCP) <a title="http://www.eclipse.org/ercp/" href="http://www.eclipse.org/ercp/">http://www.eclipse.org/ercp/</a></p></embed> <img src ="http://www.blogjava.net/beansoft/aggbug/144821.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-09-13 13:05 <a href="http://www.blogjava.net/beansoft/archive/2007/09/13/144821.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Code Manager .SWT 0.5 a 发布, GPLv3, 带 Eclipse 项目源码, 操作视频</title><link>http://www.blogjava.net/beansoft/archive/2007/09/11/144355.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Tue, 11 Sep 2007 12:34:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/09/11/144355.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/144355.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/09/11/144355.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/144355.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/144355.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 基于SWT 的资料管理小软件, 可以抓取网页, 保存图片代码等&nbsp;&nbsp;<a href='http://www.blogjava.net/beansoft/archive/2007/09/11/144355.html'>阅读全文</a><img src ="http://www.blogjava.net/beansoft/aggbug/144355.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-09-11 20:34 <a href="http://www.blogjava.net/beansoft/archive/2007/09/11/144355.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>BlogJava 备份文章阅读器: 离线HTML备份(含源码, SWT)</title><link>http://www.blogjava.net/beansoft/archive/2007/07/17/130759.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Tue, 17 Jul 2007 02:57:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/07/17/130759.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/130759.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/07/17/130759.html#Feedback</comments><slash:comments>10</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/130759.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/130759.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.blogjava.net/beansoft/archive/2007/07/17/130759.html'>阅读全文</a><img src ="http://www.blogjava.net/beansoft/aggbug/130759.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-07-17 10:57 <a href="http://www.blogjava.net/beansoft/archive/2007/07/17/130759.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SWT 在微软 Pocket PC 上运行成功</title><link>http://www.blogjava.net/beansoft/archive/2007/07/03/127812.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Tue, 03 Jul 2007 04:51:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/07/03/127812.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/127812.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/07/03/127812.html#Feedback</comments><slash:comments>10</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/127812.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/127812.html</trackback:ping><description><![CDATA[<p>看 SWT 源码的时候注意到他们的一些地方写着支持 Mobile Device, 后来看了 SWT 的下载包的确有相关的 PPC 版本. 于是经过一番折腾和查找资料, 终于让简单的 SWT 应用在我的 多普达838(Windows Mobile 5.0) 和 Pocket PC 模拟器上运行成功了(开发的时候用模拟器还是很方便的). 先放一下截图, 遗憾的是好像只支持 IBM J9 虚拟机(手机版), 而且还是试用版90天的. 以后有空把步骤和资料整理一下:</p> <p>在 Eclipse 3.3 下开发:</p> <p><img alt="swt_ppc Dev" src="http://www.blogjava.net/images/blogjava_net/beansoft/20752/r_swt_ppc_dev.png"><br><a href="http://www.blogjava.net/beansoft/gallery/20752.html">Return to Gallery</a>&nbsp;| <a href="http://www.blogjava.net/images/blogjava_net/beansoft/20752/o_swt_ppc_dev.png">Original Image</a></p> <p>在手机上运行:</p> <p><img alt="http://www.blogjava.net/images/blogjava_net/beansoft/20752/o_swt_ppc.gif" src="http://www.blogjava.net/images/blogjava_net/beansoft/20752/o_swt_ppc.gif"></p> <p>看来以后可以研究研究给自己的多普达写点小应用了, 不过访问注册表这些东西还是没法做. 这就是 Java 的缺陷之一, 不论号称多么强大的 UI 组件库, 最后也不能和能提供本机 FileView, ListView, FolderView, Registry 的 Windows 组件库相比. RCP 的应用大部分集中在画图, IDE, 简单的多页视图这些方面,&nbsp;国外的算法集中的多一些. 如果真要做像 Lotus 8 那样的定制 SWT 组件界面的应用, 有不是一般公司做的了,&nbsp;自己画组件的代码, 还是挺复杂的.&nbsp;所以个人一直对 RCP 不太看好, 因为现在的 .NET 实在太厉害了, 不管是 Windows 版还是手机版, 不过这些都是一家之言了, 哈哈.</p> <p>源码和普通的 SWT 没什么两样, 唯一的限制: 1) 类文件应该是 1.4 版本; 2) 不能用自定义组件(C开头的).</p> <p>&nbsp;</p> <p>import org.eclipse.swt.*;<br>import org.eclipse.swt.events.SelectionAdapter;<br>import org.eclipse.swt.events.SelectionEvent;<br>import org.eclipse.swt.widgets.*;<br>import org.eclipse.swt.layout.*;  <p>public class HelloWorld {<br>static private Button button1;<br>static private Button button2;<br>static private TreeItem treeItem2;<br>static private TreeItem treeItem1;<br>static private Tree tree1;<br>static private Label label1;<br>static private Text text1;<br>static private Label label2;<br>static private Slider slider1;<br>static private ProgressBar progressBar1;  <p>public static void main(String[] args) {<br>Display display = new Display();  <p>/*<br>* Create a Shell with the default style i.e. full screen, no decoration<br>* on PocketPC. Alternative: 'new Shell(display, SWT.CLOSE)' to get the<br>* Pocket PC 'Ok' button.<br>*/<br>Shell shell = new Shell(display);<br>RowLayout shellLayout = new RowLayout(org.eclipse.swt.SWT.VERTICAL);<br>shellLayout.fill = true;<br>shellLayout.type = SWT.VERTICAL;  <p>/*<br>* Set a text so that the top level Shell also appears in the Pocket PC<br>* task list<br>*/<br>shell<br>.setText("\u5fae\u8f6f PocketPC \u624b\u673a SWT HelloWorld \u793a\u4f8b By BeanSoft");  <p>/*<br>* Set a menu bar to follow UI guidelines on Pocket PC<br>*/<br>Menu mb = new Menu(shell, SWT.BAR);<br>shell.setMenuBar(mb);  <p>/*<br>* Add widgets<br>*/<br>shell.setLayout(shellLayout);<br>shell.setSize(358, 208);<br>{<br>button1 = new Button(shell, SWT.PUSH | SWT.CENTER);<br>button1.setText("\u9000\u51fa!");<br>button1.setBounds(0, 0, 126, 28);<br>button1.addSelectionListener(new SelectionAdapter() {<br>public void widgetSelected(SelectionEvent evt) {<br>button1WidgetSelected(evt);<br>}<br>});<br>}<br>{<br>button2 = new Button(shell, SWT.RADIO | SWT.LEFT);<br>button2.setText("Radio");<br>button2.setBounds(147, 0, 63, 28);<br>}<br>{<br>tree1 = new Tree(shell, SWT.NONE);<br>tree1.setBounds(0, 28, 126, 56);<br>{<br>treeItem1 = new TreeItem(tree1, SWT.NONE);<br>treeItem1.setText("treeItem1");<br>{<br>treeItem2 = new TreeItem(treeItem1, SWT.NONE);<br>treeItem2.setText("treeItem2");<br>}<br>}<br>}<br>{<br>progressBar1 = new ProgressBar(shell, SWT.NONE);<br>progressBar1.setSelection(50);<br>}<br>{<br>label1 = new Label(shell, SWT.NONE);<br>label1.setText("Code Manager .SWT \u624b\u673a\u7248");<br>}<br>{<br>slider1 = new Slider(shell, SWT.NONE);<br>slider1.setSelection(20);<br>}<br>{<br>label2 = new Label(shell, SWT.NONE);<br>label2.setText("<a href="http://www.blogjava.net/beansoft&quot;);">http://www.blogjava.net/beansoft");</a><br>}<br>{<br>text1 = new Text(shell, SWT.MULTI | SWT.WRAP);<br>text1<br>.setText("SWT \u7ec8\u4e8e\u5728 Pocket PC \u4e0a\u8fd0\u884c\u6210\u529f\u4e86!\nVM: IBM J9\n\u4f5c\u8005: \u5218\u957f\u70af");<br>}  <p>shell.open();<br>while (!shell.isDisposed()) {<br>if (!display.readAndDispatch())<br>display.sleep();<br>}<br>}  <p>private static void button1WidgetSelected(SelectionEvent evt) {<br>System.out.println("button1.widgetSelected, event=" + evt);<br>System.exit(0);<br>}<br>}</p><img src ="http://www.blogjava.net/beansoft/aggbug/127812.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-07-03 12:51 <a href="http://www.blogjava.net/beansoft/archive/2007/07/03/127812.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>BlogJava 备份文章阅读器+离线浏览备份(含源码,SWT)</title><link>http://www.blogjava.net/beansoft/archive/2007/06/20/125255.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Wed, 20 Jun 2007 02:32:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/06/20/125255.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/125255.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/06/20/125255.html#Feedback</comments><slash:comments>12</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/125255.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/125255.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 终于支持离线备份了, 保存所有文章为MHT格式,欢迎试用!&nbsp;&nbsp;<a href='http://www.blogjava.net/beansoft/archive/2007/06/20/125255.html'>阅读全文</a><img src ="http://www.blogjava.net/beansoft/aggbug/125255.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-06-20 10:32 <a href="http://www.blogjava.net/beansoft/archive/2007/06/20/125255.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Code Manager .SWT 公开源代码</title><link>http://www.blogjava.net/beansoft/archive/2007/05/16/117861.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Wed, 16 May 2007 07:42:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/05/16/117861.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/117861.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/05/16/117861.html#Feedback</comments><slash:comments>10</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/117861.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/117861.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.blogjava.net/beansoft/archive/2007/05/16/117861.html'>阅读全文</a><img src ="http://www.blogjava.net/beansoft/aggbug/117861.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-05-16 15:42 <a href="http://www.blogjava.net/beansoft/archive/2007/05/16/117861.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>给 CTabItem 加入隐藏/显示功能</title><link>http://www.blogjava.net/beansoft/archive/2007/04/09/109416.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Mon, 09 Apr 2007 07:17:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/04/09/109416.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/109416.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/04/09/109416.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/109416.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/109416.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 修改 CTabItem 类的源码加入隐藏/显示功能&nbsp;&nbsp;<a href='http://www.blogjava.net/beansoft/archive/2007/04/09/109416.html'>阅读全文</a><img src ="http://www.blogjava.net/beansoft/aggbug/109416.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-04-09 15:17 <a href="http://www.blogjava.net/beansoft/archive/2007/04/09/109416.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在 SWT 中嵌入 Word 窗口</title><link>http://www.blogjava.net/beansoft/archive/2007/04/03/108231.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Tue, 03 Apr 2007 09:20:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/04/03/108231.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/108231.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/04/03/108231.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/108231.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/108231.html</trackback:ping><description><![CDATA[<p>SWT 中可以嵌入 ActiveX 控件, 例如 Word 组件, 但是我还不知道怎么操纵里面的东西.</p> <p><img alt="http://www.blogjava.net/images/blogjava_net/beansoft/20752/o_word_in_swt.png" src="http://www.blogjava.net/images/blogjava_net/beansoft/20752/o_word_in_swt.png"></p> <p>&nbsp;</p> <p>代码如下(OleFrame 等玩意都是微软专利...):</p> <p>&nbsp;</p> <p><font color="#0080ff">package test;<br>import org.eclipse.swt.SWT;<br>import org.eclipse.swt.graphics.Point;<br>import org.eclipse.swt.graphics.Rectangle;<br>import org.eclipse.swt.layout.FillLayout;<br>import org.eclipse.swt.ole.win32.OleClientSite;<br>import org.eclipse.swt.ole.win32.OleFrame;<br>import org.eclipse.swt.widgets.Display;<br>import org.eclipse.swt.widgets.Shell; </font> <p><font color="#0080ff">public class CompositeDemoIncludeWord extends org.eclipse.swt.widgets.Composite {<br>private OleFrame oleFrame1; </font> <p><font color="#0080ff">/**<br>* Auto-generated main method to display this <br>* org.eclipse.swt.widgets.Composite inside a new Shell.<br>*/<br>public static void main(String[] args) {<br>showGUI();<br>}<br>/**<br>* Auto-generated method to display this <br>* org.eclipse.swt.widgets.Composite inside a new Shell.<br>*/<br>public static void showGUI() {<br>Display display = Display.getDefault();<br>Shell shell = new Shell(display);<br>shell.setText("Word in SWT");<br>new CompositeDemoIncludeWord(shell, SWT.NULL); </font> <p><font color="#0080ff">shell.setLayout(new FillLayout());<br>shell.layout();<br>shell.setSize(600, 400); </font> <p><font color="#0080ff">shell.open();<br>while (!shell.isDisposed()) {<br>if (!display.readAndDispatch())<br>display.sleep();<br>}<br>} </font> <p><font color="#0080ff">public CompositeDemoIncludeWord(org.eclipse.swt.widgets.Composite parent, int style) {<br>super(parent, style);<br>initGUI();<br>} </font> <p><font color="#0080ff">private void initGUI() {<br>try {<br>FillLayout thisLayout = new FillLayout(<br>org.eclipse.swt.SWT.HORIZONTAL);<br>this.setLayout(thisLayout);<br>this.setSize(229, 54);<br>{<br>oleFrame1 = new OleFrame(this, SWT.NONE);<br>{<br>try {<br>OleClientSite site = new org.eclipse.swt.ole.win32.OleClientSite (oleFrame1, org.eclipse.swt.SWT.NONE, "Word.Document");<br>site.setBounds(0, 0, 104, 54);<br>site.doVerb (org.eclipse.swt.ole.win32.OLE.OLEIVERB_SHOW); <br>} catch (org.eclipse.swt.SWTException e) {<br>String str = "Create OleClientSite Error" + e.toString ();<br>System.out.println (str);<br>return;<br>}<br>}<br>} </font> <p><font color="#0080ff">this.layout();<br>} catch (Exception e) {<br>e.printStackTrace();<br>}<br>}</font> <p><font color="#0080ff">}</font></p><img src ="http://www.blogjava.net/beansoft/aggbug/108231.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-04-03 17:20 <a href="http://www.blogjava.net/beansoft/archive/2007/04/03/108231.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关注 SWT Nebula 项目</title><link>http://www.blogjava.net/beansoft/archive/2007/03/28/107045.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Wed, 28 Mar 2007 10:42:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/03/28/107045.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/107045.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/03/28/107045.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/107045.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/107045.html</trackback:ping><description><![CDATA[<p>最近发现 Nebula 项目又增加了几个控件, 虽然还没提供下载, 但是应该很快有了, 持续关注中, 希望有我可以用的组件.</p> <p><a title="http://www.eclipse.org/nebula/" href="http://www.eclipse.org/nebula/">http://www.eclipse.org/nebula/</a></p> <li><a>Widgets &nbsp;&nbsp;<img alt="" src="http://www.eclipse.org/eclipse.org-common/themes/Phoenix/images/leftnav_bullet_down.gif" border="0"></a> <li><a href="http://www.eclipse.org/nebula/widgets/grid/grid.php">&nbsp;&nbsp;&nbsp;&nbsp;Grid</a> <li><a href="http://www.eclipse.org/nebula/widgets/cdatetime/cdatetime.php">&nbsp;&nbsp;&nbsp;&nbsp;CDateTime</a> <li><a href="http://www.eclipse.org/nebula/widgets/ctabletree/ctabletree.php">&nbsp;&nbsp;&nbsp;&nbsp;CTableTree</a> <li><a href="http://www.eclipse.org/nebula/widgets/compositetable/compositetable.php">&nbsp;&nbsp;&nbsp;&nbsp;CompositeTable</a> <li><a href="http://www.eclipse.org/nebula/widgets/pgroup/pgroup.php">&nbsp;&nbsp;&nbsp;&nbsp;PGroup</a> <li><a href="http://www.eclipse.org/nebula/widgets/pshelf/pshelf.php">&nbsp;&nbsp;&nbsp;&nbsp;PShelf</a> <li><a href="http://www.eclipse.org/nebula/widgets/gallery/gallery.php">&nbsp;&nbsp;&nbsp;&nbsp;Gallery</a> <li><a href="http://www.eclipse.org/nebula/widgets/formattedtext/formattedtext.php">&nbsp;&nbsp;&nbsp;&nbsp;FormattedText</a> <li><a href="http://www.eclipse.org/nebula/widgets/datechooser/datechooser.php">&nbsp;&nbsp;&nbsp;&nbsp;DateChooser</a></li><img src ="http://www.blogjava.net/beansoft/aggbug/107045.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-03-28 18:42 <a href="http://www.blogjava.net/beansoft/archive/2007/03/28/107045.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SWT CLabel  支持渐变色背景的Demo代码</title><link>http://www.blogjava.net/beansoft/archive/2007/03/27/106649.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Tue, 27 Mar 2007 05:28:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/03/27/106649.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/106649.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/03/27/106649.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/106649.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/106649.html</trackback:ping><description><![CDATA[<p>昨天无意中看到了 CLabel 组件支持渐变色的背景, 这样 Code Manager .SWT 实现了如下的相册浏览效果:</p> <p><img alt="http://www.blogjava.net/images/blogjava_net/beansoft/20752/o_codeman_pic_graden.png" src="http://www.blogjava.net/images/blogjava_net/beansoft/20752/o_codeman_pic_graden.png"><br>左边的模拟选中, 右边的模拟未选中时候的显示.</p> <p>相关的方法:</p> <p><strong>void org.eclipse.swt.custom.CLabel.setBackground(Color[] colors, int[] percents)</strong></p> <p>Specify a gradient of colours to be drawn in the background of the CLabel.  <p>For example, to draw a gradient that varies from dark blue to blue and then to white and stays white for the right half of the label, use the following call to setBackground:<pre>	clabel.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), 
		                           display.getSystemColor(SWT.COLOR_BLUE),
		                           display.getSystemColor(SWT.COLOR_WHITE), 
		                           display.getSystemColor(SWT.COLOR_WHITE)},
		               new int[] {25, 50, 100});
 </pre>
<dl>
<dt>Parameters: 
<dd><b>colors</b> an array of Color that specifies the colors to appear in the gradient in order of appearance from left to right; The value <code>null</code> clears the background gradient; the value <code>null</code> can be used inside the array of Color to specify the background color. 
<dd><b>percents</b> an array of integers between 0 and 100 specifying the percent of the width of the widget at which the color should change; the size of the percents array must be one less than the size of the colors array. 
<dt>Throws: 
<dd>SWTException 
<ul>
<li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed 
<li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver 
<li>ERROR_INVALID_ARGUMENT - if the values of colors and percents are not consistent </li></ul></dd></dl>
<p><strong>void org.eclipse.swt.custom.CLabel.setBackground(Color[] colors, int[] percents, boolean vertical)</strong></p>
<p>Specify a gradient of colours to be drawn in the background of the CLabel. 
<p>For example, to draw a gradient that varies from dark blue to white in the vertical, direction use the following call to setBackground:<pre>	clabel.setBackground(new Color[]{display.getSystemColor(SWT.COLOR_DARK_BLUE), 
		                           display.getSystemColor(SWT.COLOR_WHITE)},
		                 new int[] {100}, true);
 </pre>
<dl>
<dt>Parameters: 
<dd><b>colors</b> an array of Color that specifies the colors to appear in the gradient in order of appearance from left/top to right/bottom; The value <code>null</code> clears the background gradient; the value <code>null</code> can be used inside the array of Color to specify the background color. 
<dd><b>percents</b> an array of integers between 0 and 100 specifying the percent of the width/height of the widget at which the color should change; the size of the percents array must be one less than the size of the colors array. 
<dd><b>vertical</b> indicate the direction of the gradient. True is vertical and false is horizontal. 
<dt>Throws: 
<dd>SWTException 
<ul>
<li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed 
<li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver 
<li>ERROR_INVALID_ARGUMENT - if the values of colors and percents are not consistent </li></ul>
<dt>Since: 
<dd>3.0</dd></dl>
<p>相关的 Demo 代码(无法完全编译, 但是核心代码已经通过粗体标注, 就是调用如上的方法):</p>
<p>&nbsp;</p>
<p><font color="#0080ff">package codeman.w; </font>
<p><font color="#0080ff">import java.io.ByteArrayInputStream; </font>
<p><font color="#0080ff">import org.eclipse.jface.dialogs.MessageDialog;<br>import org.eclipse.swt.layout.FillLayout;<br>import org.eclipse.swt.layout.GridData;<br>import org.eclipse.swt.layout.GridLayout;<br>import org.eclipse.swt.layout.RowData;<br>import org.eclipse.swt.layout.RowLayout;<br>import org.eclipse.swt.widgets.Display;<br>import org.eclipse.swt.widgets.Event;<br>import org.eclipse.swt.widgets.FileDialog;<br>import org.eclipse.swt.widgets.Label;<br>import org.eclipse.swt.widgets.Listener;<br>import org.eclipse.swt.widgets.Shell;<br>import org.eclipse.swt.widgets.Text;<br>import org.eclipse.swt.widgets.ToolTip;<br>import org.eclipse.swt.graphics.Color;<br>import org.eclipse.swt.graphics.Image;<br>import org.eclipse.swt.graphics.Point;<br>import org.eclipse.swt.graphics.Rectangle;<br>import org.eclipse.swt.SWT;<br>import org.eclipse.swt.custom.CLabel;<br>import org.eclipse.swt.custom.ControlEditor;<br>import org.eclipse.swt.events.FocusEvent;<br>import org.eclipse.swt.events.FocusListener;<br>import org.eclipse.swt.events.KeyAdapter;<br>import org.eclipse.swt.events.KeyEvent;<br>import org.eclipse.swt.events.MouseAdapter;<br>import org.eclipse.swt.events.MouseEvent;<br>import org.eclipse.swt.events.MouseListener;<br>import org.eclipse.swt.events.MouseTrackListener;<br>import org.eclipse.swt.events.PaintEvent;<br>import org.eclipse.swt.events.PaintListener; </font>
<p><font color="#0080ff">import beansoft.codeman.manager.FileVOManager;<br>import beansoft.codeman.manager.ManagerFactory;<br>import beansoft.codeman.manager.PictureVOManager;<br>import beansoft.codeman.valuebean.FileVO;<br>import beansoft.codeman.valuebean.PictureVO;<br>import beansoft.jsp.StringUtil; </font>
<p><font color="#0080ff">import codeman.u.FileUtil;<br>import codeman.u.SWTUtil; </font>
<p><font color="#0080ff">import com.cloudgarden.resource.SWTResourceManager; </font>
<p><font color="#0080ff">import examples.fileviewer.IconCache; </font>
<p><font color="#0080ff">/**<br>* 图片缩略图面板, 显示一个图片和标题, 提供重命名标题的操作, 提供双击显示全屏图片的功能.<br>*/<br>public class HhumbnailImageComposite extends org.eclipse.swt.widgets.Composite {<br>{<br>// Register as a resource user - SWTResourceManager will<br>// handle the obtaining and disposing of resources<br>SWTResourceManager.registerResourceUser(this);<br>} </font>
<p><font color="#0080ff">/**<br>* The picture value object.<br>*/<br>private PictureVO pictureVO;<br>/**<br>* Whether this panel is selected.<br>*/<br>private boolean selected;<br>/**<br>* This label is used to display the image.<br>*/<br>private CLabel cLabelImage; </font>
<p><font color="#0080ff">/**<br>* The editor's text box.<br>*/<br>private Text text;<br>/**<br>* The editor for the title label.<br>*/<br>private ControlEditor editor;<br>/**<br>* This label displays title and image icon.<br>*/<br>private CLabel labelTitle; </font>
<p><font color="#0080ff">/**<br>* The image to display.<br>*/<br>private Image image; </font>
<p><font color="#0080ff">/**<br>* Display a tip about detail info of this picture when mouse hover on.<br>*/<br>final ToolTip imageInfoTip = new ToolTip(getShell(), SWT.DEFAULT);<br>/**<br>* Auto-generated main method to display this<br>* org.eclipse.swt.widgets.Composite inside a new Shell.<br>*/<br>public static void main(String[] args) {<br>showGUI();<br>} </font>
<p><font color="#0080ff">/**<br>* Auto-generated method to display this org.eclipse.swt.widgets.Composite<br>* inside a new Shell.<br>*/<br>public static void showGUI() {<br>Display display = Display.getDefault();<br>Shell shell = new Shell(display); </font>
<p><font color="#0080ff">HhumbnailImageComposite inst = new HhumbnailImageComposite(shell, SWT.NULL);<br>Point size = inst.getSize();<br>shell.setLayout(new RowLayout());<br>shell.layout();<br>if (size.x == 0 &amp;&amp; size.y == 0) {<br>inst.pack();<br>shell.pack();<br>} else {<br>Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y);<br>shell.setSize(shellBounds.width, shellBounds.height);<br>}<br>shell.open();<br>while (!shell.isDisposed()) {<br>if (!display.readAndDispatch())<br>display.sleep();<br>}<br>} </font>
<p><font color="#0080ff">public HhumbnailImageComposite(org.eclipse.swt.widgets.Composite parent, int style) {<br>super(parent, style);<br>// Init icon cache<br>IconCache.initResources(Display.getDefault());<br>image = SWTResourceManager.getImage("icon.ico");<br>initGUI();<br>initTooltip(); </font>
<p><font color="#0080ff">editor = new ControlEditor(labelTitle);<br>editor.horizontalAlignment = SWT.RIGHT;<br>editor.verticalAlignment = SWT.BOTTOM;<br>editor.grabHorizontal = true;<br>editor.grabVertical = false; </font>
<p><font color="#0080ff">// this.setSize(400, 420); </font>
<p><font color="#0080ff">// $hide&gt;&gt;$<br>labelTitle.setImage(IconCache.getIconForFileName(labelTitle.getText()));<br>RowData rowdata = new RowData(100, 100);<br>this.setLayoutData(rowdata);<br>setSelected(false); <br>// $hide&lt;&lt;$ <br>}<br>/**<br>* Init the tip about detail info of this picture when mouse hover on.<br>*/<br>private void initTooltip() { </font>
<p><font color="#0080ff">{<br>imageInfoTip.setText("Picture Info");<br>imageInfoTip.setAutoHide(true);<br>}<br>cLabelImage.addMouseTrackListener(new MouseTrackListener() {<br>public void mouseEnter(MouseEvent e) {<br>//tip.setVisible(true);<br>} </font>
<p><font color="#0080ff">public void mouseExit(MouseEvent e) {<br>imageInfoTip.setVisible(false);<br>} </font>
<p><font color="#0080ff">public void mouseHover(MouseEvent e) {<br>imageInfoTip.setVisible(true);<br>}<br>}); <br>} </font>
<p><font color="#0080ff">private void initGUI() {<br>try {<br>GridLayout thisLayout = new GridLayout();<br>this.setLayout(thisLayout);<br>this.setBackground(SWTResourceManager.getColor(255, 255, 255));<br>// this.addMouseListener(new MouseAdapter() {<br>// public void mouseDown(MouseEvent evt) {<br>// rootMouseDown(evt);<br>// }<br>// });<br>// this.addKeyListener(new KeyAdapter() {<br>// public void keyPressed(KeyEvent evt) {<br>// rootKeyPressed(evt);<br>// }<br>// });<br>// this.setSize(190, 88);<br>{<br>GridData cLabelImageLData = new GridData();<br>cLabelImageLData.horizontalAlignment = GridData.FILL;<br>cLabelImageLData.verticalAlignment = GridData.FILL;<br>cLabelImageLData.grabExcessVerticalSpace = true;<br>cLabelImageLData.grabExcessHorizontalSpace = true;<br>cLabelImage = new CLabel(this, SWT.NONE);<br>cLabelImage.setLayoutData(cLabelImageLData);<br>cLabelImage.setBackground(SWTResourceManager.getColor(255, 255, 255));<br>cLabelImage.addMouseListener(new MouseAdapter() {<br>public void mouseDown(MouseEvent evt) {<br>cLabelImageMouseDown(evt);<br>}<br>public void mouseDoubleClick(MouseEvent evt) {<br>bringUpFullImageViewer();<br>}<br>}); </font>
<p><font color="#0080ff">cLabelImage.addPaintListener(new PaintListener() {<br>public void paintControl(PaintEvent evt) {<br>cLabelImagePaintControl(evt);<br>}<br>});<br>} </font>
<p><font color="#0080ff">{<br>labelTitle = new CLabel(this, SWT.NONE);<br>labelTitle.setText("test.jpg");<br>GridData lableTitleLData = new GridData(); </font>
<p><font color="#0080ff">lableTitleLData.horizontalAlignment = GridData.FILL;<br>lableTitleLData.grabExcessHorizontalSpace = true;<br>labelTitle.setLayoutData(lableTitleLData);<br>labelTitle.setAlignment(SWT.CENTER);<br>// lableTitle.setBackground(SWTResourceManager.getColor(185, 220, 255));<br>labelTitle.addMouseListener(new MouseAdapter() {<br>public void mouseDown(MouseEvent evt) {<br>lableTitleMouseDown(evt);<br>}<br>}); </font>
<p><font color="#0080ff">} </font>
<p><font color="#0080ff">this.layout();<br>} catch (Exception e) {<br>e.printStackTrace();<br>}<br>} </font>
<p><font color="#0080ff">/**<br>* Paint image on the label again with specified size.<br>* <br>* @param evt<br>*/<br>private void cLabelImagePaintControl(PaintEvent evt) {<br>if (image == null) {<br>return;<br>} </font>
<p><font color="#0080ff">Rectangle bounds = image.getBounds(); </font>
<p><font color="#0080ff">if (bounds == null) {<br>return;<br>} </font>
<p><font color="#0080ff">Point size = cLabelImage.getSize(); </font>
<p><font color="#0080ff">if (size.equals(new Point(0, 0))) {<br>return;<br>} </font>
<p><font color="#0080ff">int MAX_WIDTH = size.x;// TODO: 缩放后的图片最大宽度<br>int MAX_HEIGHT = size.y;// TODO: 缩放后的图片最大高度<br>int imageWidth = bounds.width;<br>int imageHeight = bounds.height; </font>
<p><font color="#0080ff">// determine thumbnail size from MAX_WIDTH and MAX_HEIGHT<br>int thumbWidth = MAX_WIDTH;<br>int thumbHeight = MAX_HEIGHT;<br>double thumbRatio = (double) thumbWidth / (double) thumbHeight;<br>double imageRatio = (double) imageWidth / (double) imageHeight;<br>if (thumbRatio &lt; imageRatio) {<br>thumbHeight = (int) (thumbWidth / imageRatio);<br>} else {<br>thumbWidth = (int) (thumbHeight * imageRatio);<br>}<br>// 如果图片小于所略图大小, 不作处理<br>// if (imageWidth &lt; MAX_WIDTH &amp;&amp; imageHeight &lt; MAX_HEIGHT) {<br>// thumbWidth = imageWidth;<br>// thumbHeight = imageHeight;<br>// } </font>
<p><font color="#0080ff">evt.gc.drawImage(image, 0, 0, bounds.width, bounds.height, 0, 0,<br>thumbWidth, thumbHeight); </font>
<p><font color="#0080ff">// evt.gc.drawImage(image, srcX, srcY, srcWidth, srcHeight, destX,<br>// destY, destWidth, destHeight)<br>} </font>
<p><font color="#0080ff">/**<br>* Set the image size to new one.<br>* @param width<br>* @param height<br>*/<br>public void setImageSize(int width, int height) {<br>// cLabelImage.setSize(width, height);<br>this.setSize(width + 20, height + 20);<br>try {<br>RowData data = (RowData) this.getLayoutData();<br>data.width = width + 20;<br>data.height = height + 20;<br>this.setLayoutData(data);<br>} catch (Exception e) {<br>e.printStackTrace();<br>} </font>
<p><font color="#0080ff">}<br>public void setImageSize(Point size) {<br>setImageSize(size.x, size.y);<br>} </font>
<p><font color="#0080ff">/**<br>* @return the image The image to display.<br>*/<br>public Image getImage() {<br>return image;<br>} </font>
<p><font color="#0080ff">/**<br>* @param image<br>* The image to display.<br>*/<br>public void setImage(Image image) {<br>this.image = image;<br>}<br>/**<br>* When the label is clicked, then set up the file name text editor.<br>* @param evt<br>*/<br>private void lableTitleMouseDown(MouseEvent evt) {<br>{<br>if(text == null) {<br>text = new Text(labelTitle, SWT.MULTI | SWT.WRAP | SWT.BORDER);<br>// Validate file name<br>SWTUtil.addFileNameValidateToolTip(text);<br>Listener textListener = new Listener() {<br>public void handleEvent(final Event e) {<br>switch (e.type) {<br>case SWT.FocusOut:<br>// text.setVisible(false);<br>renameFileNameToDB();<br>break;<br>case SWT.Traverse:<br>switch (e.detail) {<br>case SWT.TRAVERSE_RETURN:<br>// renameFileNameToDB();<br>// FALL THROUGH<br>// break;<br>case SWT.TRAVERSE_ESCAPE:<br>text.setVisible(false);<br>e.doit = false;<br>}<br>break;<br>}<br>// text.dispose();<br>}<br>};<br>// <br>text.addListener(SWT.FocusOut, textListener);<br>text.addListener(SWT.Traverse, textListener);<br>}<br>text.setText(labelTitle.getText()); </font>
<p><font color="#0080ff">// Point size = text.computeSize(SWT.DEFAULT, SWT.DEFAULT);<br>editor.minimumWidth = labelTitle.getSize().x;<br>editor.minimumHeight = labelTitle.getSize().y;<br>text.setVisible(true);<br>editor.setEditor(text); <br>text.selectAll();<br>text.setFocus();<br>}<br>// <br>}<br>/**<br>* Rename the file and update icon.<br>*/<br>private void renameFileNameToDB() {<br>if(!FileUtil.isValidFileName(text.getText())) {<br>return;<br>}<br>PictureVO nodeVO = getPictureVO(); </font>
<p><font color="#0080ff">if (nodeVO == null) {<br>return;<br>} </font>
<p><font color="#0080ff">if (text.getText() != null<br>&amp;&amp; text.getText().length() &gt; 0) {<br>if (text.getText().equals(<br>nodeVO.getDescription())) {<br>return;<br>}<br>nodeVO.setDescription(text.getText());<br>PictureVOManager picManager = ManagerFactory<br>.getPictureVOManager();<br>if (picManager.updatePictureVO(nodeVO)) {<br>labelTitle.setText(text.getText());<br>labelTitle.setImage(IconCache<br>.getIconForFileName(nodeVO<br>.getDescription()));<br>text.setVisible(false);<br>} else {<br>// FIXME! Using SWT to Beep!<br>java.awt.Toolkit<br>.getDefaultToolkit().beep();<br>}<br>} else {<br>// FIXME! Using SWT to Beep!<br>java.awt.Toolkit.getDefaultToolkit()<br>.beep();<br>} </font>
<p><font color="#0080ff">} </font>
<p><font color="#0080ff">/**<br>* @return the pictureVO<br>*/<br>public PictureVO getPictureVO() {<br>return pictureVO;<br>} </font>
<p><font color="#0080ff">/**<br>* @param pictureVO the pictureVO to set<br>*/<br>public void setPictureVO(PictureVO pictureVO) {<br>this.pictureVO = pictureVO;<br>if(pictureVO == null) {<br>this.dispose();<br>}<br>if(pictureVO != null &amp;&amp; pictureVO.getFile() != null) {<br>try {<br>Image img = new Image(Display.getCurrent(), new ByteArrayInputStream(pictureVO.getFile()));<br>this.setImage(img);<br>// Update label text and image<br>this.labelTitle.setText(pictureVO.getDescription());<br>labelTitle.setImage(IconCache.getIconForFileName(labelTitle.getText())); <br>this.setToolTipText(pictureVO.getNotesText());<br>imageInfoTip.setMessage(SWTUtil.getImageDetailInfo(img, pictureVO.getDescription(), pictureVO.getSize()));<br>} catch (Exception e) {<br>e.printStackTrace();<br>}<br>}<br>}<br>/**<br>* 打开单独的窗口对图片进行浏览.<br>*/<br>public void bringUpFullImageViewer() {<br>// System.out.println("this.mouseDown, event=" + evt);<br>if(text != null ) {<br>if(text.isVisible()) {<br>text.setVisible(false);<br>}<br>}<br>Display display = Display.getDefault(); </font>
<p><font color="#0080ff">final Shell shell = new Shell (this.getShell(), SWT.SHELL_TRIM | SWT.APPLICATION_MODAL);<br>ImageViewerComposite inst = new ImageViewerComposite(shell, SWT.NULL);<br>inst.setPictureVO(this.getPictureVO());<br>Point size = inst.getSize();<br>shell.setLayout(new FillLayout());<br>shell.layout(); </font>
<p><font color="#0080ff">shell.pack();<br>shell.setSize(400, 400);<br>shell.open();<br>while (!shell.isDisposed()) {<br>if (!display.readAndDispatch())<br>display.sleep();<br>}<br>}<br>/**<br>* Export the PictureVO to disk.<br>* @param parent<br>* @param vo<br>*/<br>public static void exportPicture(Shell parent, PictureVO vo) {<br>if(parent == null || vo == null) {<br>return;<br>}<br>FileDialog fileDialog = new FileDialog(parent, SWT.SAVE);<br>fileDialog.setText("Export Picture File");<br>fileDialog.setFilterExtensions(new String[] { "*.jpg;*.gif;*.png;*.jpeg;*.ico;*.bmp",<br>"*.*" });<br>fileDialog.setFilterNames(new String[] {"Pictures(" + fileDialog.getFilterExtensions ()[0] + ")", "Any File(*.*)"<br>}); </font>
<p><font color="#0080ff">fileDialog.setFileName(vo.getDescription()); </font>
<p><font color="#0080ff">String filePath = fileDialog.open(); </font>
<p><font color="#0080ff">if (!StringUtil.isEmpty(filePath)) {<br>try {<br>FileUtil.writeFileBinary(filePath, vo.getFile());<br>} catch (Exception e) {<br>MessageDialog.openError(parent, "Error export picture",<br>"Failed to access file: " + e.getMessage());<br>return;<br>}<br>} <br>} </font>
<p><font color="#0080ff">/**<br>* @return the selected<br>*/<br>public boolean isSelected() {<br>return selected;<br>} </font>
<p><font color="#0080ff"><strong>/**<br>* 设置是否选中, 显示渐变色.<br>* @param selected the selected to set<br>*/<br>public void setSelected(boolean selected) {<br>this.selected = selected;<br>if(selected) {<br>Color bg = Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION);<br>Color fg = Display.getCurrent().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);<br>labelTitle.setBackground(new Color[]{SWTResourceManager.getColor(58, 146, 254), <br>SWTResourceManager.getColor(2, 87, 229)},<br>new int[] {100}, true); <br>labelTitle.setForeground(fg);<br>cLabelImage.setBackground(new Color[]{SWTResourceManager.getColor(58, 146, 254), <br>SWTResourceManager.getColor(2, 87, 229)},<br>new int[] {100}, true);<br>this.setBackground(bg);<br>} else {<br>labelTitle.setBackground(new Color[]{SWTResourceManager.getColor(254, 254, 252), <br>SWTResourceManager.getColor(238, 226, 221)},<br>new int[] {100}, true); <br>labelTitle.setForeground((Color)null);<br>cLabelImage.setBackground(new Color[]{SWTResourceManager.getColor(254, 254, 252), <br>SWTResourceManager.getColor(238, 226, 221)},<br>new int[] {100}, true);<br>this.setBackground(SWTResourceManager.getColor(255, 255, 255));<br>}<br>}<br></strong>/**<br>* Hide text editor when click on the image label.<br>* @param evt<br>*/<br>private void cLabelImageMouseDown(MouseEvent evt) {<br>if(text != null ) {<br>if(text.isVisible()) {<br>text.setVisible(false);<br>}<br>}<br>} </font>
<p><font color="#0080ff">}</font></p><img src ="http://www.blogjava.net/beansoft/aggbug/106649.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-03-27 13:28 <a href="http://www.blogjava.net/beansoft/archive/2007/03/27/106649.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SWT输入时验证并提示文件名非法的小例子</title><link>http://www.blogjava.net/beansoft/archive/2007/03/26/106434.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Mon, 26 Mar 2007 08:11:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/03/26/106434.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/106434.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/03/26/106434.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/106434.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/106434.html</trackback:ping><description><![CDATA[<p>Windows 资源管理器中修改文件名的话如果出错会弹出类似的提示, 我用SWT实现了这个功能, 并编写了一个工具方法来完成此任务, 详情参考代码.</p> <p>参考资料:<a href="http://www.blogjava.net/cuiyuelei/archive/2007/02/09/99078.html">eclipse3.2的新加入控件--ToolTip小实例</a></p> <p><img alt="http://www.blogjava.net/images/blogjava_net/beansoft/20752/o_filename_validate.png" src="http://www.blogjava.net/images/blogjava_net/beansoft/20752/o_filename_validate.png"></p> <p>&nbsp;</p> <p><font color="#0080ff">import org.eclipse.swt.layout.FillLayout;<br>import org.eclipse.swt.layout.GridData;<br>import org.eclipse.swt.layout.GridLayout;<br>import org.eclipse.swt.widgets.Display;<br>import org.eclipse.swt.widgets.Shell;<br>import org.eclipse.swt.widgets.Text;<br>import org.eclipse.swt.widgets.ToolTip;<br>import org.eclipse.swt.events.KeyEvent;<br>import org.eclipse.swt.events.KeyListener;<br>import org.eclipse.swt.graphics.Point;<br>import org.eclipse.swt.graphics.Rectangle;<br>import org.eclipse.swt.SWT; </font> <p><font color="#0080ff">/**<br>* 输入时验证文件名并显示提示的例子.<br>* @author BeanSoft@126.com<br>*<br>*/<br>public class NewComposite extends org.eclipse.swt.widgets.Composite {<br>private Text text1; </font> <p><font color="#0080ff">/**<br>* Auto-generated main method to display this <br>* org.eclipse.swt.widgets.Composite inside a new Shell.<br>*/<br>public static void main(String[] args) {<br>showGUI();<br>}<br>/**<br>* Auto-generated method to display this <br>* org.eclipse.swt.widgets.Composite inside a new Shell.<br>*/<br>public static void showGUI() {<br>Display display = Display.getDefault();<br>Shell shell = new Shell(display);<br>NewComposite inst = new NewComposite(shell, SWT.NULL);<br>Point size = inst.getSize();<br>shell.setLayout(new FillLayout());<br>shell.setText("File name test");<br>shell.layout();<br>if(size.x == 0 &amp;&amp; size.y == 0) {<br>inst.pack();<br>shell.pack();<br>} else {<br>Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y);<br>shell.setSize(shellBounds.width, shellBounds.height);<br>}<br>shell.open();<br>while (!shell.isDisposed()) {<br>if (!display.readAndDispatch())<br>display.sleep();<br>}<br>} </font> <p><font color="#0080ff">public NewComposite(org.eclipse.swt.widgets.Composite parent, int style) {<br>super(parent, style);<br>initGUI();<br>addFileNameValidateToolTip(text1);<br>} </font> <p><font color="#0080ff">private void initGUI() {<br>try {<br>this.setLayout(new GridLayout());<br>this.setSize(255, 29);<br>{<br>text1 = new Text(this, SWT.BORDER);<br>GridData text1LData = new GridData();<br>text1LData.heightHint = 13;<br>text1LData.grabExcessHorizontalSpace = true;<br>text1LData.horizontalAlignment = GridData.FILL;<br>text1.setLayoutData(text1LData);<br>text1.setText("Please input a file name here");<br>}<br>this.layout();<br>} catch (Exception e) {<br>e.printStackTrace();<br>}<br>}</font> <p><font color="#0080ff">/**<br>* Add file name validation to the text control, if the text's value<br>* contains invlid file name char(s), a tooltip will be displayed to notice<br>* the user. 添加文本控件文件名验证提示功能, 如果文件名无效, 就显示出错提示的 ToolTip.<br>* <br>* @author BeanSoft<br>* @version 1.0 2007-03-25<br>* @param text -<br>* the text that need to be validated<br>*/<br>public static void addFileNameValidateToolTip(final Text text) {<br>text.addKeyListener(new KeyListener() {<br>/**<br>* Display a tip about detail info of this picture when mouse hover<br>* on.<br>*/<br>final ToolTip errorInfoTip = new ToolTip(text.getShell(),<br>SWT.BALLOON | SWT.ICON_ERROR);<br>{<br>errorInfoTip.setText("Invalid file name");<br>errorInfoTip.setAutoHide(true);<br>} </font> <p><font color="#0080ff">public void keyPressed(KeyEvent e) {<br>} </font> <p><font color="#0080ff">/**<br>* When key released, will check for filename.<br>*/<br>public void keyReleased(KeyEvent e) {<br>if (!isValidFileName(text.getText())) {<br>errorInfoTip<br>.setMessage("The file name should not contain char(s) of below:\n\\ / : * ? \" &lt; &gt; |");<br>errorInfoTip.setVisible(true);<br>e.doit = false;<br>}<br>} </font> <p><font color="#0080ff">});<br>}</font> <p><font color="#0080ff">/**<br>* 检查文件名是否合法.文件名字不能包含字符\/:*?"&lt;&gt;|<br>* @param fileName文件名,不包含路径<br>* @return boolean is valid file name<br>*/<br>public static boolean isValidFileName(String fileName)<br>{<br>boolean isValid = true;<br>String errChar = "\\/:*?\"&lt;&gt;|" //<br>if (fileName == null || fileName.length() == 0)<br>{<br>isValid = false;<br>}<br>else<br>{<br>for (int i = 0; i &lt; errChar.length(); i++)<br>{<br>if (fileName.indexOf(errChar.charAt(i)) != -1)<br>{<br>isValid = false;<br>break;<br>}<br>}<br>}<br>return isValid;<br>} </font> <p><font color="#0080ff">}</font></p><img src ="http://www.blogjava.net/beansoft/aggbug/106434.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-03-26 16:11 <a href="http://www.blogjava.net/beansoft/archive/2007/03/26/106434.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SWT 的相册(Gallery)组件,含源码下载</title><link>http://www.blogjava.net/beansoft/archive/2007/03/26/106393.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Mon, 26 Mar 2007 06:17:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/03/26/106393.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/106393.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/03/26/106393.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/106393.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/106393.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 来自Eclipse SWT 星云项目的显示图片列表的组件&nbsp;&nbsp;<a href='http://www.blogjava.net/beansoft/archive/2007/03/26/106393.html'>阅读全文</a><img src ="http://www.blogjava.net/beansoft/aggbug/106393.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-03-26 14:17 <a href="http://www.blogjava.net/beansoft/archive/2007/03/26/106393.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>今日学习: 给 SWT 加入拖放保存文件功能</title><link>http://www.blogjava.net/beansoft/archive/2007/03/21/105284.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Wed, 21 Mar 2007 07:37:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/03/21/105284.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/105284.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/03/21/105284.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/105284.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/105284.html</trackback:ping><description><![CDATA[<p>SWT的拖放功能实现除了要加入自定义的拖放类型有点复杂外, 其它的还是相对简单的. 今天就用下面的官方示例来给 Code Manager .SWT 加入文件栏的拖放保存文件功能, 导出文件功能如果能拖放完成也加入进去, 貌似需要拖放开始的时候先把附件存到一个地方然后才能从软件窗口中拖放到 Windows 的资源管理器中.</p> <p><a href="http://www.blogjava.net/images/blogjava_net/beansoft/WindowsLiveWriter/SWT_DA6E/image%7B0%7D%5B5%5D.png" atomicselection="true"><img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="171" src="http://www.blogjava.net/images/blogjava_net/beansoft/WindowsLiveWriter/SWT_DA6E/image%7B0%7D_thumb%5B3%5D.png" width="393" border="0"></a> </p> <p>&nbsp;</p> <p><font color="#0080ff">/*******************************************************************************<br>* Copyright (c) 2000, 2005 IBM Corporation and others.<br>* All rights reserved. This program and the accompanying materials<br>* are made available under the terms of the Eclipse Public License v1.0<br>* which accompanies this distribution, and is available at<br>* </font><a href="http://www.eclipse.org/legal/epl-v10.html"><font color="#0080ff">http://www.eclipse.org/legal/epl-v10.html</font></a><br><font color="#0080ff">*<br>* Contributors:<br>* IBM Corporation - initial API and implementation<br>*******************************************************************************/<br>package org.eclipse.swt.snippets; </font> <p><font color="#0080ff">/*<br>* Make a dropped data type depend on a target item in table<br>* <br>* For a list of all SWT example snippets see<br>* </font><a href="http://www.eclipse.org/swt/snippets/"><font color="#0080ff">http://www.eclipse.org/swt/snippets/</font></a><br><font color="#0080ff">*/<br>import java.io.*; </font> <p><font color="#0080ff">import org.eclipse.swt.*;<br>import org.eclipse.swt.dnd.*;<br>import org.eclipse.swt.layout.*;<br>import org.eclipse.swt.widgets.*; </font> <p><font color="#0080ff">public class Snippet185 { </font> <p><font color="#0080ff">public static void main (String [] args) {<br>Display display = new Display ();<br>Shell shell = new Shell (display);<br>shell.setLayout(new FillLayout());<br>Label label1 = new Label(shell, SWT.BORDER);<br>label1.setText("Drag Source");<br>final Table table = new Table(shell, SWT.BORDER);<br>for (int i = 0; i &lt; 4; i++) {<br>TableItem item = new TableItem(table, SWT.NONE);<br>if (i % 2 == 0) item.setText("Drop a file");<br>if (i % 2 == 1) item.setText("Drop text");<br>}<br>DragSource dragSource = new DragSource(label1, DND.DROP_COPY);<br>dragSource.setTransfer(new Transfer[] {TextTransfer.getInstance(), FileTransfer.getInstance()});<br>dragSource.addDragListener(new DragSourceAdapter() {<br>public void dragSetData(DragSourceEvent event) {<br>if (FileTransfer.getInstance().isSupportedType(event.dataType)) {<br>File file = new File("temp");<br>event.data = new String[] {file.getAbsolutePath()};<br>}<br>if (TextTransfer.getInstance().isSupportedType(event.dataType)) {<br>event.data = "once upon a time"<br>}<br>} <br>});<br>DropTarget dropTarget = new DropTarget(table, DND.DROP_COPY | DND.DROP_DEFAULT);<br>dropTarget.setTransfer(new Transfer[] {TextTransfer.getInstance(), FileTransfer.getInstance()});<br>dropTarget.addDropListener(new DropTargetAdapter() {<br>FileTransfer fileTransfer = FileTransfer.getInstance();<br>TextTransfer textTransfer = TextTransfer.getInstance();<br>public void dragEnter(DropTargetEvent event) {<br>if (event.detail == DND.DROP_DEFAULT) event.detail = DND.DROP_COPY;<br>}<br>public void dragOperationChanged(DropTargetEvent event) {<br>if (event.detail == DND.DROP_DEFAULT) event.detail = DND.DROP_COPY;<br>}<br>public void dragOver(DropTargetEvent event) {<br>event.detail = DND.DROP_NONE;<br>TableItem item = (TableItem)event.item;<br>if (item == null) return;<br>int itemIndex = table.indexOf(item);<br>if (itemIndex % 2 == 0) {<br>int index = 0;<br>while (index &lt; event.dataTypes.length) {<br>if (fileTransfer.isSupportedType(event.dataTypes[index])) break;<br>index++;<br>}<br>if (index &lt; event.dataTypes.length) {<br>event.currentDataType = event.dataTypes[index];<br>event.detail = DND.DROP_COPY;<br>return;<br>}<br>} else {<br>int index = 0;<br>while (index &lt; event.dataTypes.length) {<br>if (textTransfer.isSupportedType(event.dataTypes[index])) break;<br>index++;<br>}<br>if (index &lt; event.dataTypes.length) {<br>event.currentDataType = event.dataTypes[index];<br>event.detail = DND.DROP_COPY;<br>return;<br>}<br>}<br>} </font> <p><font color="#0080ff">public void drop(DropTargetEvent event) {<br>TableItem item = (TableItem)event.item;<br>if (item == null) {<br>event.detail = DND.DROP_NONE;<br>return;<br>}<br>if (fileTransfer.isSupportedType(event.currentDataType)) {<br>String[] files = (String[])event.data;<br>if (files != null &amp;&amp; files.length &gt; 0) {<br>item.setText(files[0]);<br>}<br>}<br>if (textTransfer.isSupportedType(event.currentDataType)) {<br>String text = (String)event.data;<br>if (text != null) {<br>item.setText(text);<br>}<br>}<br>}<br>});<br>shell.setSize(300, 150);<br>shell.open ();<br>while (!shell.isDisposed ()) {<br>if (!display.readAndDispatch ()) display.sleep ();<br>}<br>display.dispose ();<br>}<br>}</font></p><img src ="http://www.blogjava.net/beansoft/aggbug/105284.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-03-21 15:37 <a href="http://www.blogjava.net/beansoft/archive/2007/03/21/105284.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Jigloo 高级技巧(撰写中)</title><link>http://www.blogjava.net/beansoft/archive/2007/03/18/104581.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Sun, 18 Mar 2007 10:51:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/03/18/104581.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/104581.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/03/18/104581.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/104581.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/104581.html</trackback:ping><description><![CDATA[<p>Jigloo 非常好用, 然而当编辑的文件个头非常大的时候就不得不使用一些技巧来避免反复解析代码导致工作速度变慢.</p> <p>快捷键 Ctrl + Alt + P 可以避免 Jigloo 在每次保存修改过的代码的时候都要解析界面造成延迟.</p> <p>某些代码如果被 Jigloo 解析会造成不必要的麻烦, 例如弹出闪屏(Splash), 弹出警告对话框, 这时候可以用下列方式来避免:</p> <p>//$hide&gt;&gt;$</p> <p>多行代码</p> <p>//$hide&lt;&lt;$</p> <p>单行代码 //$hide$</p> <p>这样这些代码就不会被解析了, 可以大大加快修改进度.</p> <p>&nbsp;</p> <p>理解 Jigloo 如何解析代码(摘录自帮助文档). TODO</p> <p>&nbsp;</p> <p><big><b>Java Code and Jigloo</b></big><small><b><br><a></a><big>Parsing Code</big><br></b><br>Jigloo parses the java class to construct the visual representation of the form. If you edit the code in the source editor then your changes will be reflected in the form editor. However, this might take a few seconds, so if you are making lots of changes to the java code you might want to disable parsing temporarily till you have made your changes. You can toggle parsing on/off by hitting Ctrl+Alt+P in the source editor, or hitting the "Toggle Parsing" button in the <a href="http://127.0.0.1:62289/outline_page.html">Outline View</a>.<br>Jigloo is able to parse most common Java techniques for building GUIs as adopted by most popular GUI builders. It is also able to accomodate hand-written code to a certain degree. However, it does have limitations and these include:<br></small> <ul> <li><small>for or while loops - if multiple components are created or properties set inside a loop then Jigloo will not recognise them.</small> <li><small>if/then/else statements - Jigloo will parse all parts of an if/then/else statement. <br></small> <li><small>components passed as arguments to methods - if a JPanel is passed to a method which fills that JPanel with JButtons, say.<br></small></li></ul><small>Jigloo starts by parsing the constructors of your class. If it finds a call to other class methods (eg, if "createComponents" is a method of your class, and it is called from your constructor), then those methods will be parsed by jigloo as it encounters the method calls. Similarly, if those methods call other methods then those methods will be parsed and so on. If, in the course of parsing the constructors and all the methods called by the constructors etc, one of the "GUI initialization" methods is parsed, then jigloo will stop parsing your code. <br><i></i><br><i>The "GUI initialization" methods are by default {initGUI, initComponents, initialize, open, createPartControl, createContents, createControl and createDialogArea} but this list can be changed in the <a href="http://127.0.0.1:62289/preferences_page.html">Jigloo Preferences Page</a>.</i><br>If, however, none of the "GUI initialization" methods have been parsed then Jigloo will search the code for one of these methods (in the order in which they appear in the list) and will parse the first one it finds. Eg, if a class has methods "open" and "initialize", then "initialize" will be parsed because it appears first in the "GUI initialization" list. If none of the "GUI initialization" methods appear in a class, then every method in the class will be parsed. <br>Therefore if you always use a method "initializeGUI", say, to create your code then you would add "initializeGUI" to the start of the "GUI initialization" list.</small><br><small>By default, Jigloo will not parse code that sets a property of a component outside of the method in which that component is created. For instance, if a JLabel is created inside the initGUI method, say, but an event handler for a JButton's actionPerformed event sets the value of that JLabel's text, then that value will not be applied to the JLabel in the form editor. This prevents Jigloo from displaying a GUI which is only visible under certain conditions (eg, when a button is pressed).<br>However, if you *do* wish Jigloo to parse such property-setter calls, then there is a setting in the <a href="http://127.0.0.1:62289/preferences_page.html">Preferences Page</a> which allows you to do this.</small><br><small><br><b><a></a><big>Hiding code from Jigloo</big></b><br>However, Jigloo recognizes certain comment tags which can be used to customize the parsing/code-generation behaviour of Jigloo.<br>Code blocks can be hidden from Jigloo using the <b>//$hide&gt;&gt;$</b> and <b>//$hide&lt;&lt;$</b> tags. ie, the </small><small><b>//$hide&gt;&gt;$</b> tag should be placed on the line before the start of the block you wish to hide<b>, </b></small><small>and the </small><small><b>//$hide&lt;&lt;$</b> tag should be placed on the line after the end of the block</small><small><b>. </b></small><small>Any code inside a block marked by these tags will not be parsed by Jigloo. </small><br><small><br>If you wish to hide a single line of code, then you can place the customizable <b>//$hide$</b> comment at the end of the line.<br></small><br><small>These tags can be customized in the </small><small><a href="http://127.0.0.1:62289/preferences_page.html">Preferences Page</a>. <br>Thus you are able to design a GUI for each case of an if/then clause by hiding one half of the clause at a time.<br></small><small><b><a></a><big>Protecting code from Jigloo</big><br></b></small><small>Code blocks can also be protected from being modified by Jigloo by using the customizable <b>//$protect&gt;&gt;$ </b>and </small><small><b>//$protect&lt;&lt;$ </b>(and </small><small><b>//$protect$</b>) tags, in the same was as the tags for hiding code. </small><small>These tags can also be customized in the </small><small><a href="http://127.0.0.1:62289/preferences_page.html">Preferences Page</a>. </small><small>Any code marked by these tags will not be modified, though Jigloo may add lines of code inside those blocks.<br><small><br></small><br></small><small><a></a><b><big>Class Instantiation</big></b><br></small><small><small><br></small>As jigloo tries to render your GUI in it's Form Editor, it needs to insantiate the visual classes used and also any classes which are used as properties of these visual classes. Also, if a method is called on a visual class then Jigloo will try and instantiate the classes passed as parameters for this method. However, Jigloo will not instantiate any other classes. If you find that Jigloo is instantiating a class that you do not want it to instantiate, add this class to the "Forbidden superclasses" list in the "Class creation" tab of </small><small>the <a href="http://127.0.0.1:62289/preferences_page.html">Jigloo Preferences Page</a>. </small><small>You can define single classes or packages of superclasses which can or cannot be instantiated. Note, you are specifying superclasses, so if you allow/deny a superclass, then you are also allowing/denying any extensions of that superclass.</small><small></small><br><small><a></a><b><big>Externalizing Strings</big></b><br></small><small><b>Note:</b> If you are working on classes created by Jigloo 2.7.2 which use the getExternalizedString method, then you will need to change this method to be static before Jigloo 3.0 will be able to get the value of the externalized string.</small><br><small>Jigloo recognizes Strings externalized by Eclipse's "externalize strings" action, which creates a ResourceBundle accessor class and the appropriate calls in your code.<br>Jigloo will parse these calls, search for the properties file related to the ResourceBundle, and display the externalized string in the Form Editor. If it can't find the properties file, or the project has not been built yet, then it will display the key for the externalized string surrounded by "$" signs.</small><br><b><br><a></a>Code Generation<br></b><small>Jigloo will generate new code in accordance with the user-defined preferences set in the Jigloo <a href="http://127.0.0.1:62289/preferences_page.html#generation">preferences page.</a> You can choose whether to generate elements inside getter methods (available for Swing forms only) or whether to enclose them inside braces, comment tags or blank lines. The advantages of enclosing elements inside braces are:<br></small> <ul> <li><small>when an element is moved, if you have placed any custom code relating directly to that element inside it's braces then that custom code will be guaranteed to be moved also. If braces are not used then that code might or might not be moved, and should probably be placed inside a totally separate method instead.</small> <li><small>though unusual, nested braces can actually clarify the parent-child relationships peculiar to GUI code.</small></li></ul><small>If you change your code-generation style, you may want to completely re-format your code according to the new style (say, you decide to change from using spaces to separate code elements to using braces). </small><small>Jigloo does not do this automatically since it is a time-consuming operation. </small><small>After changing your preference, you can right-click on the form editor and choose the "Source-&gt;Reformat code to current coding style" option. <br>You can also use this powerful option to re-format code generated by hand or by other GUI builders.<br><b>Note on converting from getters:</b> If you are converting from using getters to using code blocks, the getter methods will be deleted from the code, so that if you are explicitly calling these getters from your own code, or from other classes, these getters will need to be regenerated to return the corresponding fields - but the Eclipse context menu options can be used to do this easily. Any references to the getter methods from code that is being controlled by Jigloo, however, will be changed to refer directly to the fields themselves, so the code will only need to be repaired if, for example, you are calling myJFrame.getJPanel1() from an external class after reformatting MyJFrame to not use getters..</small><img src ="http://www.blogjava.net/beansoft/aggbug/104581.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-03-18 18:51 <a href="http://www.blogjava.net/beansoft/archive/2007/03/18/104581.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Jigloo 的 KeyGen</title><link>http://www.blogjava.net/beansoft/archive/2007/03/18/104580.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Sun, 18 Mar 2007 10:40:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/03/18/104580.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/104580.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/03/18/104580.html#Feedback</comments><slash:comments>12</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/104580.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/104580.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;&nbsp;<a href='http://www.blogjava.net/beansoft/archive/2007/03/18/104580.html'>阅读全文</a><img src ="http://www.blogjava.net/beansoft/aggbug/104580.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-03-18 18:40 <a href="http://www.blogjava.net/beansoft/archive/2007/03/18/104580.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Jigloo 开发 SWT 的入门教程</title><link>http://www.blogjava.net/beansoft/archive/2007/03/18/104577.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Sun, 18 Mar 2007 09:59:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/03/18/104577.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/104577.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/03/18/104577.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/104577.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/104577.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: Jigloo 开发 SWT 的入门教程, 含图文和示例工程.&nbsp;&nbsp;<a href='http://www.blogjava.net/beansoft/archive/2007/03/18/104577.html'>阅读全文</a><img src ="http://www.blogjava.net/beansoft/aggbug/104577.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-03-18 17:59 <a href="http://www.blogjava.net/beansoft/archive/2007/03/18/104577.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Jigloo 开发 SWT 的简易教程(撰写中)</title><link>http://www.blogjava.net/beansoft/archive/2007/03/12/103373.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Mon, 12 Mar 2007 10:18:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/03/12/103373.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/103373.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/03/12/103373.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/103373.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/103373.html</trackback:ping><description><![CDATA[
		<p>作者: <a href="mailto:BeanSoft@126.com">BeanSoft@126.com</a></p>
		<p>日期: 2007.03.12</p>
		<p>转载请注明出处<a title="http://www.blogjava.net/beansoft/archive/2007/03/12/103373.html" href="/beansoft/archive/2007/03/12/103373.html">http://www.blogjava.net/beansoft/archive/2007/03/12/103373.html</a>.</p>
		<p>经常有朋友苦于自己做了一个转换工具算法, 想用图形界面封装一下, 却不知道如何下手. 本文就介绍一下如何用 Jigloo 开发一个简单的 SWT 应用把自己编写的 public String doConvert(String args) 方法封装成图形界面的版本.</p>
		<p>
				<strong>一. 搭建开发环境</strong>
		</p>
		<blockquote>
				<p>
						<strong>1. SWT 类库的下载和安装</strong>
				</p>
		</blockquote>
		<p>SWT 是 IBM 出品的类似于 AWT 的组件包, 基于 OS 组件封装模拟而成, 由 C 代码和 Java 代码混合而成. 首页: <a title="http://www.eclipse.org/swt/" href="http://www.eclipse.org/swt/">http://www.eclipse.org/swt/</a>. 详细介绍可以 Google. 本文以 Windows 版本为例进行讲解. 需要注意的是并非所有平台都能运行 SWT, 详情请参考 SWT 项目主页的介绍. 并且不同的平台需要对应平台的 SWT 运行库.</p>
		<p>截图: </p>
		<p>
				<img alt="Vista" src="http://www.eclipse.org/swt/images/vis-example.png" height="225" width="225" />
				<img alt="Windows" src="http://www.eclipse.org/swt/images/win-example.png" height="204" width="216" />
				<img alt="Linux" src="http://www.eclipse.org/swt/images/lin-example.png" height="224" width="212" />
		</p>
		<p>下载 SWT 3.3 M5 swt-3.3M5-win32-win32-x86.zip:</p>
		<p>Download from: <a href="http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops/S-3.3M5-200702091006/swt-3.3M5-win32-win32-x86.zip&amp;url=http://download.actuatechina.com/eclipse/eclipse/downloads/drops/S-3.3M5-200702091006/swt-3.3M5-win32-win32-x86.zip&amp;mirror_id=385">[China] Actuate Shanghai (http)</a> Windows 版本. 用 3.3 的好处是它运行的时候不需要再指定 library 路径了.</p>
		<p>然后参考 <a title="http://www.eclipse.org/swt/eclipse.php" href="http://www.eclipse.org/swt/eclipse.php">http://www.eclipse.org/swt/eclipse.php</a>  <strong>Developing SWT applications using Eclipse</strong> 一文中的说明搭好基于 Eclipse 的开发环境. 以下为文章内容的中文翻译:</p>
		<p>因为 SWT 被集成为 Eclipse plug-in API 的一部分, 独立运行的应用程序开发最好基于 SWT 独立版的下载. 这个文档讲帮助你安装. </p>
		<p>首先, 从<a href="http://www.eclipse.org/swt/">SWT homepage</a> 下载适于您的平台的 SWT 的.zip 文件. </p>
		<p>SWT .zip 文件可以导入到你的工作区. 选择 <i>File</i> 菜单, 然后选择 <i>Import</i> , 选中 <i>Existing Projects Into Workspace</i> 向导. (新版本的 eclipse 中, 你可以在 <i>General</i> 分类下找到 <i>Existing Projects Into Workspace</i>). </p>
		<p>
				<img alt="Existing Projects Into Workspace Wizard" src="http://www.eclipse.org/swt/images/existing.png" />
		</p>
		<p>定位向导里面的路径到你下载的 .zip 文件所在的目录. 这将会在工作区里创建一个名为 <i>org.eclipse.swt</i> 的工程. </p>
		<p>
				<img alt="Import Projects Wizard" src="http://www.eclipse.org/swt/images/import-projects.png" />
		</p>
		<p>您自己的 Java 项目可以将 SWT 项目作为依赖添加进来. 打开Java 项目的 Properties 对话框, 在 <i>Java Build Path</i> 设置页中, 包含 org.eclipse.swt 项目. </p>
		<p>
				<img alt="Project Properties" src="http://www.eclipse.org/swt/images/add-project.png" />
		</p>
		<p>将 SWT 项目作为依赖项, 你可以使用 Eclipse 的一些方便的功能例如 Javadoc 视图和代码提示(code assist). </p>
		<p>
				<img alt="SWT Eclipse Example" src="http://www.eclipse.org/swt/images/swt-example.png" />
		</p>
		<p>现在你可以在你的项目中运行任何的主类, 通过选中类然后选择菜单 <i>Run &gt; Run As &gt; Java Application.</i></p>
		<blockquote>
				<p>
						<strong>2. Jigloo 的下载和安装</strong>
				</p>
		</blockquote>
		<p>
				<a href="http://cloudgarden.com/jigloo/index.html">Jigloo</a>
				<br />能识别大多数的 FormBuilder 创建的 GUI, 例如 JBuilder 等, 运行速度比较快, 比 Visual Editor 好用. 可以编辑 AWT,Swing/SWT 的界面. 个人用免费, 商用需收费. </p>
		<p>Note: Jigloo is free for non-commercial use, but purchase of a Professional License is required for commercial use (after successfully evaluating Jigloo).  </p>
		<p>
		</p>
		<p>Eclipse:<br />2.1.*, 3.0*, 3.1*, 3.2 </p>
		<p>Java:<br />1.3, 1.4 or 5.0 </p>
		<p>Platforms: </p>
		<p>Windows, Linux (gtk) and Mac OSX. (On a Mac, only SWT GUIs can be built). </p>
		<p>下载地址: <a title="here" href="http://cloudgarden1.com/jigloo_395.zip">here</a></p>
		<p>  </p>
		<p>二. Jigloo 简单使用 </p>
		<blockquote>
				<p>1. 初识 Jigloo</p>
		</blockquote>
		<blockquote>
				<p>2. 拖拉快速搭建界面 </p>
				<p>拖放, 预览. </p>
				<p>3. 加入事件响应代码 </p>
				<p>4. 测试</p>
		</blockquote>
		<p>三. 打包发布应用 </p>
		<blockquote>
				<p>1. 目录布局以及复制依赖文件 </p>
				<p>2. 编写启动脚本 </p>
				<p>3. 用 pack200 打包发布(可以大大减小个头)</p>
		</blockquote>
		<p>四. FAQ </p>
		<blockquote>
				<p>欢迎提问, 并来 Wiki 交流.</p>
		</blockquote>
<img src ="http://www.blogjava.net/beansoft/aggbug/103373.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-03-12 18:18 <a href="http://www.blogjava.net/beansoft/archive/2007/03/12/103373.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>可以运行SWT的精简版JRE 1.4.2_04, 压缩后仅1.3MB</title><link>http://www.blogjava.net/beansoft/archive/2007/03/07/102381.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Wed, 07 Mar 2007 05:31:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/03/07/102381.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/102381.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/03/07/102381.html#Feedback</comments><slash:comments>6</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/102381.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/102381.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 可以可靠的运行简单的SWT应用的包, 当然如果你用到了别的包请自己加入 jre\lib\rt.jar&nbsp;&nbsp;<a href='http://www.blogjava.net/beansoft/archive/2007/03/07/102381.html'>阅读全文</a><img src ="http://www.blogjava.net/beansoft/aggbug/102381.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-03-07 13:31 <a href="http://www.blogjava.net/beansoft/archive/2007/03/07/102381.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SWT学习笔记1 - Swing 和 SWT 代码的简单比较</title><link>http://www.blogjava.net/beansoft/archive/2007/03/06/102186.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Tue, 06 Mar 2007 07:56:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/03/06/102186.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/102186.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/03/06/102186.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/102186.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/102186.html</trackback:ping><description><![CDATA[<p>&nbsp;&nbsp;&nbsp; 笔者过去学习过Swing(也算是AWT的增强版吧), 现在开始学习一下 SWT, 还没有开始深入 JFace 和 RCP, 一步步来吧. 先学好基础的, 又不用着急做项目用. 本文讨论的内容仅限于我已知的 SWT, Swing 范围, 希望能对有 Swing 经验的人快速了解 SWT 有所帮助.</p> <p>&nbsp;&nbsp; 第一个不同点就是 SWT 的类库结构不像 Swing, 没有单一的父组件. SWT 中有好几个父类:</p> <li><b>Widget</b> —— 基本的 SWT GUI 组件（类似于 Java AWT 中的 <i>Component</i> 和 Swing 中的 <i>JComponent</i>）。Widget 是一个抽象类。  <li><b>Control</b> —— 拥有操作系统的对等物的窗口小部件（换句话说，在操作系统中具有同一身份）。Control 是一个抽象类。  <li><b>Composite</b> —— 包含其他控件的控件（类似于 Java AWT 中的 <i>Container</i> 和 Swing 中的 <i>JPanel</i>）。  <li><b>Item</b> —— 其他控件包含的窗口小部件（该控件可能不是复合控件），比如列表和表。注意，包含一些项的控件很少包含其他控件，反之亦然。Item 是一个抽象类。</li> <p><em>注: 请参考文章 SWT 和 JFace，第 1 部分: 简介 </em><a title="http://www.ibm.com/developerworks/cn/opensource/os-jface1/" href="http://www.ibm.com/developerworks/cn/opensource/os-jface1/"><em>http://www.ibm.com/developerworks/cn/opensource/os-jface1/</em></a><em>&nbsp;来了解更多信息.</em></p> <p>SWT 的组件不能随意继承, 其源代码中会标注: <strong><font color="#ff0000">IMPORTANT: This class is &lt;em&gt;not&lt;/em&gt; intended to be subclassed</font></strong>.如果你那样做了, 运行的时候 SWT 系统就会报错, 也不能任意包含子组件. 某些组件, 例如 Tree, 只能接收 TreeItem 作为其子组件. 这样在写一些可重用的图形组件的时候必须注意, Swing 中的写法不能直接套用在 SWT 中.</p> <p>Swing 的所有图形界面类都继承自 java.awt.Container, 这意味着所有的 Swing 组件都可以包含任意的子组件, 也可以被继承. 这是两个类库的第一个不同点.</p> <p>第二个不同点就是 SWT 没有利用 Java 的自带垃圾收集功能来管理对象的销毁,&nbsp; 大部分对象都必须调用 dispose() 方可完成资源的释放.</p> <p>第三个不同点就是在组件的显示上, SWT 抽象了一个 Display 对象来处理 SWT 和操作系统底层组件的通信, 资源申请释放, 事件循环, 任何显示的 SWT 组件必须有且仅有一个 Display 对象.</p> <p>第四个不同点就是 Swing 的组件实现了 MVC 机制, 但是 SWT 没有(目前来看)提供 MVC 机制. 也就是说绝大多数 SWT 组件都是不可以更换显示的外观的, 我的意思是例如像皮肤这样的机制, 例如:实现一个 Office 2003 外观的橙色菜单条的显示, SWT 是不能通过简单的编码来实现的(也许有, 但是还没找到相关的资料).</p> <p>SWT 的每个组件对象提供了 setData(Object) 这样的方法来给组件存储一个或者多个数据对象, Swing 中没有类似的概念.</p> <p>第五个不同点就是绝大多数的 SWT 组件创建的时候都必须指定父组件和风格属性, 也就是必须有一个 parent 对象, 也不能运行的时候动态变更父组件, 具体例如 Menu 对象里有 <font color="#0080ff">Decorations getParent ()</font> , 但是并无对应的 <font color="#0080ff">setParent()</font> 方法. 组件创建之后即自动加入父组件成为其一员, 这和 Swing 的必须通过 add() 方法来加入父组件是不一样的. 大多数的 SWT 组件不提供无参数的构造器, 这就意味这他们不是 JavaBean, 这点上 Swing 的绝大多数组件都是 JavaBean.</p> <p>总结以上这些内容我们可以感觉到 SWT 更像是操作系统本地组件的一种封装, 而不是基于 Java OO 的概念对其进行映射, 其优点就是数据结构简单.</p> <p>好了, 接下来还是通过一些代码来比较吧.</p> <p>第一个是经典的 Hello World.</p> <ul> <li>SWT 版本</li></ul> <p><font color="#0080ff">import org.eclipse.swt.widgets.*; </font></p> <p><font color="#0080ff">public class SWTHelloWorld { </font> <p><font color="#0080ff">public static void main(String[] args) {<br>Display display = new Display();<br>Shell shell = new Shell(display);<br>shell.<strong><em>setText</em></strong>("Hello World!");<br>shell.open();<br><strong>while (!shell.isDisposed()) {<br>if (!display.readAndDispatch())<br>display.sleep();<br>}<br>display.dispose();<br>}</strong><br>}</font></p> <ul> <li>Swing 版本</li></ul> <p><font color="#0080ff"></font>&nbsp;</p> <p><font color="#0080ff">import javax.swing.JFrame; </font> <p><font color="#0080ff">public class SwingHelloWorld { </font> <p><font color="#0080ff">public static void main(String[] args) {<br>JFrame frame = new JFrame();<br>frame.<strong><em>setTitle</em></strong>("Hello World!");<br>frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);<br>frame.setSize(400, 400);<br>frame.setVisible(true);<br>}<br>}</font></p> <p>SWT 的 Text 属性在不同的组件中有不同的意思, 对于窗体来说它是标题, 对于控件来说它是显示的文本, Swing 中这个是分开的, 对于窗口来说是 Title 属性, 对于控件来说是 Text 属性. SWT 的事件循环基于显式的 while 模式, 而 Swing 已经在底层封装好了事件的循环和处理. 所以这两段代码最明显的不同就是 SWT 多了时间循环的部分, 即文中粗体的部分.</p> <p>接着我们来看看继承 SWT 的组件会有什么后果. 在 Swing 中继承一个组件然后向其中添加子组件, 例如建立一个自定义的工具栏, 然后向其中加入子栏目, 并最后显示出来, 这是经常进行的操作, 再看看 SWT 中:</p> <p>&nbsp;</p> <p><font color="#0080ff">import org.eclipse.swt.widgets.Display;<br>import org.eclipse.swt.widgets.Shell;<br>import org.eclipse.swt.widgets.ToolItem;<br>import org.eclipse.swt.SWT; </font> <p><font color="#0080ff">public class NewToolBar extends org.eclipse.swt.widgets.ToolBar { </font> <p><font color="#0080ff">public static void main(String[] args) {<br>try {<br>Display display = Display.getDefault();<br>Shell shell = new Shell(display);<br>new NewToolBar(shell, SWT.NULL); </font> <p><font color="#0080ff">shell.open();<br>while (!shell.isDisposed()) {<br>if (!display.readAndDispatch())<br>display.sleep();<br>}<br>} catch (Exception e) {<br>e.printStackTrace();<br>}<br>} </font> <p><font color="#0080ff">public NewToolBar(Shell parent, int style) {<br>super(parent, style);<br>new ToolItem(this, SWT.NULL);<br>} </font> <p><font color="#0080ff">}</font> <p>运行它, 很不幸的, 出错了:</p> <p><em>org.eclipse.swt.SWTException: Subclassing not allowed<br>at org.eclipse.swt.SWT.error(SWT.java:3478)<br>at org.eclipse.swt.SWT.error(SWT.java:3401)<br>at org.eclipse.swt.SWT.error(SWT.java:3372)<br>at org.eclipse.swt.widgets.Widget.error(Widget.java:432)<br>at org.eclipse.swt.widgets.ToolBar.checkSubclass(ToolBar.java:178)<br>at org.eclipse.swt.widgets.Widget.&lt;init&gt;(Widget.java:135)<br>at org.eclipse.swt.widgets.Control.&lt;init&gt;(Control.java:95)<br>at org.eclipse.swt.widgets.Scrollable.&lt;init&gt;(Scrollable.java:72)<br>at org.eclipse.swt.widgets.Composite.&lt;init&gt;(Composite.java:93)<br>at org.eclipse.swt.widgets.ToolBar.&lt;init&gt;(ToolBar.java:98)<br>at NewToolBar.&lt;init&gt;(NewToolBar.java:48)<br>at NewToolBar.main(NewToolBar.java:35)</em></p> <p>我不知道 SWT 为何要避免继承, 但是我只能遗憾的告诉 Swing 程序员, 除了少部分顶级容器外, 绝大多数组件都是不可继承的, 在你想继承一个组件, 这之前请先阅读其源码是否如文首那般写着: <strong><font color="#ff0000">IMPORTANT: This class is &lt;em&gt;not&lt;/em&gt; intended to be subclassed, </font></strong>否则您可能正在写一段语法上没错但是逻辑上有错的代码.</p><img src ="http://www.blogjava.net/beansoft/aggbug/102186.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-03-06 15:56 <a href="http://www.blogjava.net/beansoft/archive/2007/03/06/102186.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SWT 一个简单的自适应 CLabel 大小的画图组件</title><link>http://www.blogjava.net/beansoft/archive/2007/03/02/101510.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Fri, 02 Mar 2007 09:27:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/03/02/101510.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/101510.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/03/02/101510.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/101510.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/101510.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 拖动窗口大小里面缩略图也会跟着缩放&nbsp;&nbsp;<a href='http://www.blogjava.net/beansoft/archive/2007/03/02/101510.html'>阅读全文</a><img src ="http://www.blogjava.net/beansoft/aggbug/101510.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-03-02 17:27 <a href="http://www.blogjava.net/beansoft/archive/2007/03/02/101510.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SWT/JFACE的一些资料</title><link>http://www.blogjava.net/beansoft/archive/2007/03/02/101400.html</link><dc:creator>BeanSoft</dc:creator><author>BeanSoft</author><pubDate>Fri, 02 Mar 2007 02:48:00 GMT</pubDate><guid>http://www.blogjava.net/beansoft/archive/2007/03/02/101400.html</guid><wfw:comment>http://www.blogjava.net/beansoft/comments/101400.html</wfw:comment><comments>http://www.blogjava.net/beansoft/archive/2007/03/02/101400.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/beansoft/comments/commentRss/101400.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/beansoft/services/trackbacks/101400.html</trackback:ping><description><![CDATA[<p></p> <h4><a href="http://allenyoung.javaeye.com/blog/28277">如何在SWT中使鼠标的状态变成忙碌</a></h4><img src ="http://www.blogjava.net/beansoft/aggbug/101400.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/beansoft/" target="_blank">BeanSoft</a> 2007-03-02 10:48 <a href="http://www.blogjava.net/beansoft/archive/2007/03/02/101400.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>