现在选择哪个 Java GUI 框架?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/281342/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Which Java GUI framework to choose now?
提问by Marko
Which GUI framework/library would you choose if you were to start your new project nowor in the near future?
如果您现在或在不久的将来开始新项目,您会选择哪个 GUI 框架/库?
It has to be free for commercial use and cross platform.
它必须免费用于商业用途和跨平台。
I have been a happy swing user, but Sun seems like pushing swingto deprecation, while pushing Javafx, which is not yet ready for prime time.
我一直是一个快乐的 Swing 用户,但 Sun 似乎在推动Swing弃用,同时推动Javafx,它尚未准备好进入黄金时段。
There's also SWT, but it seems like it has issues on Linux.
还有SWT,但它似乎在 Linux 上有问题。
What is your Gui library/framework of choice?
你选择的 Gui 库/框架是什么?
EDIT: Sun has canceled swingxproject. From the forum comments on http://swingx.dev.java.netseems like majority of Sun resources that previously worked on core swing are now developing JavaFx full time.
编辑:Sun 已经取消了Swingx项目。从http://swingx.dev.java.net上的论坛评论看来,以前在核心 Swing 上工作的大部分 Sun 资源现在都在全职开发 JavaFx。
采纳答案by Daniel Spiewak
I think that despite Sun's mismanagement, Swing is still an excellent framework. You can do a lotwith it, especially if that "lot" involves custom rendered UI controls. If your application needs a branded LAF, or even just a few complex custom controls here and there, Swing is exactly what you want.
我认为尽管 Sun 管理不善,但 Swing 仍然是一个出色的框架。你可以用它做很多事情,特别是如果那个“很多”涉及自定义呈现的 UI 控件。如果您的应用程序需要一个品牌的 LAF,或者甚至只是一些复杂的自定义控件,那么 Swing 正是您想要的。
On the other side of the coin, I do like SWT quite a lot. It gets a bad rap because everyone used to think it was IBM's ploy to take over Java, but it's really just another UI framework that is quite complementary to Swing. I would not advise using SWT for super-complex graphics rendering (specifically: compositing) or for creating really non-trivial custom controls, but for everything else it is really dandy. The API itself gets a lot of criticism because of things like reliance on bit masks and a user-managed event dispatch loop, but most of those things are pretty transparent once you get used to them. The components themselves are a lot simpler than Swing's (in terms of extensibility and similar), which means that the API can be proportionally simpler. I can actually remember how to create and populate a table in SWT; whereas I don't think I have everhandled that in Swing without Google's assistance.
另一方面,我非常喜欢 SWT。它得到了不好的说唱,因为每个人过去都认为 IBM 接管 Java 是一种策略,但它实际上只是另一个与 Swing 非常互补的 UI 框架。我不建议将 SWT 用于超级复杂的图形渲染(特别是:合成)或创建真正重要的自定义控件,但对于其他一切,它真的很花哨。由于依赖位掩码和用户管理的事件调度循环等因素,API 本身受到了很多批评,但是一旦您习惯了这些东西,其中的大部分内容就非常透明。组件本身比 Swing 的简单很多(在可扩展性和相似性方面),这意味着 API 可以成比例地更简单。我实际上记得如何在 SWT 中创建和填充表;曾经在没有谷歌帮助的情况下在 Swing 中处理过这个问题。
SWT's biggest problem right now is the stable version depends on Carbon on Mac OS X. This means that SWT apps can only run 32bit on Java 5 (or 32bit on SoyLatte). As for other platforms, SWT is phenomenal on Windows (Vista and XP) and almost as good on GTK Linux. I have not (in recent past) had any issues with SWT on Linux, so I'm a bit surprised that you would mention it as a sore point.
SWT 目前最大的问题是稳定版本依赖于 Mac OS X 上的 Carbon。这意味着 SWT 应用程序只能在 Java 5 上运行 32 位(或在 SoyLatte 上运行 32 位)。至于其他平台,SWT 在 Windows(Vista 和 XP)上表现出色,在 GTK Linux 上几乎同样出色。我(最近)在 Linux 上没有遇到过 SWT 问题,所以我有点惊讶你会提到它是一个痛点。
Coming back to your question: it all depends on what your application needs. If it's a flashy custom-styled application with tons of custom controls and complex compositing, Swing is the only game in town. However, if a simpler API is more important to you, or if your users demand the ultimate in platform LAF fidelity, SWT is the best choice.
回到您的问题:这完全取决于您的应用程序需要什么。如果它是具有大量自定义控件和复杂合成的华丽自定义样式应用程序,那么 Swing 是镇上唯一的游戏。但是,如果更简单的 API 对您来说更重要,或者如果您的用户要求最终的平台 LAF 保真度,SWT 是最佳选择。
回答by Aaron Digulla
Right now, I'm either using SWT or Qt (Jambi).
现在,我要么使用 SWT 要么使用 Qt (Jambi)。
Swing didn't evolve in the last, say, 10 years, bugs aren't fixed, the development has stopped in favor of JavaFX, so you won't ever see any new features, too. JavaFX will probably look great but is still vaporware and it's made by the people who let Swing starve to death, so I'm not putting any money on it.
Swing 在过去的 10 年里没有发展,错误没有修复,开发已经停止支持 JavaFX,所以你也不会看到任何新功能。JavaFX 可能看起来很棒,但仍然是雾件,它是由让 Swing 饿死的人制作的,所以我不会在上面投入任何资金。
Between SWT and Qt, I prefer to use Qt because it's a very mature and powerful framework made by people who know what they are doing (well, most of the time anyway :)) and SWT if the license for the new project wasn't compatible to Qt's.
在 SWT 和 Qt 之间,我更喜欢使用 Qt,因为它是一个非常成熟和强大的框架,由知道自己在做什么的人(好吧,大部分时间无论如何 :))和 SWT(如果新项目的许可证没有)与 Qt 兼容。
回答by Elie
I still use Swing, and will continue to do so until it is no longer supported at all. Thanks for the heads up about Javafx, I'll have to look into that one now.
我仍在使用 Swing,并将继续使用,直到它不再受支持为止。感谢有关 Javafx 的提醒,我现在必须研究一下。

