Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java GUI 设计 » SWT  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 示例:用SWT OS API代替JNI集成DLL
kite





发贴: 121
积分: 14
于 2005-02-25 11:25 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我做了一个demo,采用SWT的内部API,将一个用gcc做的UI控件于SWT应用集成,并且不采用JNI。如果SWT的Fans们喜欢的话,我可以把demo放上来。


作者 Re:示例:用SWT OS API代替JNI集成DLL [Re:kite]
leowu2000



版主


发贴: 258
积分: 50
于 2005-02-25 13:18 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
欢迎欢迎!最好除了代码多给一些你的思路。

leowu2000 edited on 2005-02-25 16:08

Eclipse邮件列表
作者 Re:示例:用SWT OS API代替JNI集成DLL [Re:kite]
cnfree



CJSDN高级会员


发贴: 118
积分: 13
于 2005-02-25 14:05 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
好东东,期待中


Eclipse专业论坛:http://bbs.rcp.cn[img]http://bbs.rcp.cn/logo.gif[/img]
我的Blog:
http://blog.csdwiki.org
http://spaces.msn.com/members/cnfree2000
作者 Re:示例:用SWT OS API代替JNI集成DLL [Re:kite]
kite





发贴: 121
积分: 14
于 2005-02-25 16:45 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
这个demo是将scintilla封装为swt的UI组件,我已经把scintilla的组件放到了压缩包里,如果对scintilla感兴趣的话,可以去这里:scintilla.org。解压缩之后,请copy你的swt.jar和swt-win32-3063.dll到合适的目录,记住:目前在swt 3.1M5中有问题。然后,执行java -Djava.library.path="你的swt的dll所在的目录" org.eclipse.swt.widgets.ScintillaTest 1. 参数可以是1或0,用来区别是否支持代码折叠。目前的版本很初级,只是一个示例,说明在swt下可以不用JNI,也可以利用部分用C/C++写的现有控件。

swt-scintilla.rar (171.69k)



作者 Re:示例:用SWT OS API代替JNI集成DLL [Re:kite]
kite





发贴: 121
积分: 14
于 2005-02-25 16:48 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
忘了说明了:用的是eclipse 3.0.1版本中的swt,如果没有,可以去eclipse.org上下载单独的swt package,不必下载整个eclipse。


作者 Re:示例:用SWT OS API代替JNI集成DLL [Re:kite]
kite





发贴: 121
积分: 14
于 2005-02-25 16:55 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
如果谁有兴趣,可以从scintilla.org下载它的linux版本,然后使用她的scilex的so和swt的linux版本做一下测试,应该是没有问题的。另外,我是用jdk1.5编译的,如果你不能运行的话,可以用jdk1.4重新编译一下即可。另外,由于其中有一个地方目前使用了特殊的技巧,只能支持jdk1.4以上的版本。


作者 Re:示例:用SWT OS API代替JNI集成DLL [Re:kite]
cnfree



CJSDN高级会员


发贴: 118
积分: 13
于 2005-02-25 17:55 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
看了一下,利用org.eclipse.swt.internal.win32.OS调用Window的API,再Window2000、XP下还可以设置程序半透明。昨天我还在用Java的Robot类截屏,不过速度相当慢,需要150毫秒,用.net调用Win32API只要几十毫秒,你这个帖子正好给我启发,看看能不能调用先。


Eclipse专业论坛:http://bbs.rcp.cn[img]http://bbs.rcp.cn/logo.gif[/img]
我的Blog:
http://blog.csdwiki.org
http://spaces.msn.com/members/cnfree2000
作者 Re:示例:用SWT OS API代替JNI集成DLL [Re:kite]
kite





发贴: 121
积分: 14
于 2005-02-25 18:27 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
我这样做的思路是来源于SWT本身,既然其可以用一套Java API支持多种平台,我么为什么不能利用swt本身来和平台打交道呢?通过查阅SWT的API发现其于平台交互的部分基本上都是在OS类中,并且其API相对于JNI来将还是要舒服多了,虽然有一些平台的功能不能通过其利用,但是很多功能还是可以的,比如集成一些UI控件,这样我们就不用过多考虑JNI代码的跨平台特性,即使需要,也可以将其最小化。随着SWT的发展,我相信有很多于平台特性相关的feature会被逐步添加,目前launch的eclipse desktop proposal就是一个信号。当然,如果只就windows平台来讲,目前的feature已经很强大了,如于ActiveX 的集成。这样,我们就可以利用不同语言的特性来编写合适的部分,然后统一在Java的环境下组装,其实这样做的本身也是一种“SOA”。只是一点个人感想,希望不喜欢SWT的兄弟们,不要扁我。


作者 Re:示例:用SWT OS API代替JNI集成DLL [Re:kite]
kite





发贴: 121
积分: 14
于 2005-02-26 10:11 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
更新了一下,可以同时支持swt2.x ,3.0.x,3.1.x。取消了对sun.nio.ch.DirectBuffer的依赖,应该可以在jdk 1.3和SWT 2.x上运行,我这目前没有,如果谁有,请试一下,看看是否可以,告诉我一声。由于本人对c/c++和win32不甚寥寥,所以目前的代码只是能运行,是否是最佳方法,请win32高手帮助看一下。

swt-scintilla.rar (172.05k)



作者 Re:示例:用SWT OS API代替JNI集成DLL [Re:kite]
kite





发贴: 121
积分: 14
于 2005-02-26 11:54 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
不好意思,打包失误,更新的demo不能运行在swt 2。1上,你可以自己改一下代码即可。用下面的代码替换ScintillaText类中的setProperty方法,
public void setProperty(String name , String value) {
  byte[] bytes = (name + "\0").getBytes();
  int ref = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, 8*bytes.length);
  OS.MoveMemory(ref, bytes, 8*bytes.length);
  TCHAR lParam = new TCHAR(getCodePage(),value,true);
  OS.SendMessage(handle,SCI_SETPROPERTY,ref,lParam);
  OS.GlobalFree(ref);
}



作者 Re:示例:用SWT OS API代替JNI集成DLL [Re:kite]
yipsilon





发贴: 248
积分: 31
于 2005-03-06 12:29 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
Eclipse的文档说不赞成使用internal包中的类, 因为发布新版本时里面的改动都会很大...



flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923