Swing 到 SWT 转换:有哪些缺点?

发布于 2024-10-08 21:54:10 字数 174 浏览 3 评论 0原文

我们正在考虑将 Swing 应用程序移植到 SWT/JFace,以获得更原生的外观和感觉、更快的 UI 渲染速度和更少的错误。

有没有人已经做过这样的移植并想分享一些信息,特别是我们应该预料到的缺点?提前致谢。

PS:也许这应该是一个 wiki,因为接受它作为最终答案是没有意义的。

We are considering to port our Swing applications to SWT/JFace to get a more native look and feel, more UI rendering speed and less bugs.

Is there anybody who already has done such a port and wants to share some information, especially disadvantages we should expect? Thanks in advance.

PS: Maybe this rather should be a wiki, because it makes no sense to accept one as the ultimate answer.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

放肆 2024-10-15 21:54:10

根据我的经验:

  • SWT 并非适用于所有平台。确保所有目标平台都受支持。

  • 修复 SWT 中的错误比 Swing 中的错误要困难得多:SWT 中的大多数类都是最终类,或者在构造函数中包含恶意检查以确保没有人扩展它们,包已签名(因此您不能简单地替换类),到目前为止,我多次尝试从源代码编译 SWT - 但失败了。 StackOverflow 上有 47K 个点,人们会想象我应该能够编译 Java 代码...

  • Swing 有很多自定义组件,SWT 只有 Nebula 项目,它不是很活跃。虽然可以混合使用 Swing 和 SWT 组件,但这不适合胆小的人。

PS:相比 Swing,我仍然更喜欢 SWT :-)

From my experience:

  • SWT isn't available for all platforms. Make sure all your target platforms are supported.

  • Fixing bugs in SWT is much harder than in Swing: Most classes in SWT are final or contain hostile checks in the constructor to make sure no one extends them, the package is signed (so you can't simply replace classes), and so far, I tried several times to compile SWT from sources - and failed. With 47K points on StackOverflow, one would imagine that I should be able to compile Java code...

  • There are lots of custom components for Swing, SWT just has project Nebula which isn't very active. While it's possible to mix Swing and SWT components, that's not for the faint of heart.

PS: I still prefer SWT over Swing :-)

攒一口袋星星 2024-10-15 21:54:10

我目前正在对我正在编写的应用程序做同样的事情。 Swing 小部件缺乏本机支持,甚至缺乏适当的“模拟”,这让我非常沮丧。我在开发时使用 Ubuntu(因此也使用 Gnome),我立即注意到像下拉菜单这样简单的东西在 Swing 中完全无法正确渲染,但在 SWT 中却可以正常工作(在 Swing 中,它们周围没有绘制边框,并且禁用的菜单项完全渲染)与其他情况下的情况不同)。

除了您必须完全重写“View”类这一事实之外,没有任何巨大的障碍需要克服,这可能是您所期望的。

当您提到 SWT 时,如果您要实现的功能需要 JFace 和 RCP,那么您可能还应该包括 JFace 和 RCP。他们可能会这样做。

最后的建议:甚至不敢将两者混合。你会后悔的。您的下一个版本应该是 Swing 或 SWT——如果您尝试将两者互操作,您将遇到严重的错误,从而导致您失去客户。

I am currently doing the same thing with an application that I am writing. The lack of native support -- or even proper "emulation" -- of widgets with Swing frustrated me very much. I use Ubuntu (and thus Gnome) when developing and immediately I noticed that something as simple as drop down menus are totally improperly rendered with Swing but work fine with SWT (in Swing, no border is drawn around them and disabled menu items are rendered totally differently than they would otherwise be).

There aren't any huge hurdles to overcome other than the fact that you have to totally rewrite your "View" classes, which is probably what you would expect.

When you say SWT, you should also probably include JFace and RCP if the features you're implementing call for this. They probably do.

Final advice: don't even dare mix the two. You will regret it. Your next release should either be Swing or SWT -- if you try to interop the two, you will run into serious bugs which will cause you to lose clients.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文