Java GUI 开发的未来?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3270771/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 01:05:09  来源:igfitidea点击:

Future of GUI development in Java?

javauser-interfaceapiswingswt

提问by soc

Considering that

考虑到

  • Sun/Oracle decided to not develop Swing any further after they "invented" JavaFX
  • JavaFX doesn't really work and some consider it a failure already
  • the not really platform-independent nature of SWT, the manual task to dispose GUI elements and the necessity to bundle platform-specific libraries
  • Sun/Oracle 在“发明”JavaFX 后决定不再进一步开发 Swing
  • JavaFX 并没有真正起作用,有些人认为它已经失败了
  • SWT 并非真正独立于平台的性质、处理 GUI 元素的手动任务以及捆绑平台特定库的必要性

is there another way out?

还有其他出路吗?

If I would like to do GUI development on the JVM

如果我想在 JVM 上做 GUI 开发

  • with a good API (Swing and SWT are not bad, but they are not really good either.)
  • which "feels" responsive (still a problem today with Swing and SWT, despite the claims that this is solved.)
  • which won't be obsolete in a few years what decision should I make?
  • 具有良好的 API(Swing 和 SWT 还不错,但它们也不是很好。)
  • 它“感觉”响应迅速(尽管声称已经解决了这个问题,但今天仍然是 Swing 和 SWT 的一个问题。)
  • 几年后不会过时的我应该做出什么决定?

Is there even a third option available or a possibility there might be one in the future?

是否还有第三种选择,或者将来可能会有第三种选择?

An option

一个选项

  • which is fast and responsive (Not Swing's ideology of "If it's not fast, it is the developer's fault")
  • with native look and feel
  • with a single library which runs on all platforms
  • 快速且响应迅速(不是 Swing 的“如果它不快,那是开发人员的错”的意识形态)
  • 具有原生外观和感觉
  • 使用在所有平台上运行的单个库

Is this realistic?

这是现实的吗?

Thanks!

谢谢!

=========

==========

To clarify: If I have to start a new software project on the JVM, there are several existing options, like using SWT or Swing, using Swing with third-party libraries like SwingX, JIDE, JGoodies, Flamingo or using application frameworks like Netbeans Platform or Eclipse RCP. Is there a supported/suggested way which weakens the pain normally associated with Java GUI development?

澄清一下:如果我必须在 JVM 上启动一个新的软件项目,有几个现有的选项,比如使用 SWT 或 Swing,将 Swing 与第三方库(如 SwingX、JIDE、JGoodies、Flamingo)一起使用或使用应用程序框架(如 Netbeans Platform)或 Eclipse RCP。是否有一种支持/建议的方法可以减轻通常与 Java GUI 开发相关的痛苦?

采纳答案by the.duckman

You won't find an objective answer to this question, only personal preferences and options.

你不会找到这个问题的客观答案,只有个人喜好和选择。

SWT

声波

My personal preference is SWT. I started using it, when Swing was to bad to be an option. SWT is "just" a layer on top of the native windowing APIs and thus applications written with SWT feel like natively written applications. Those can also be screwed up. No API will ever be safe from bad developers. The performance is as fast as it can get in my experience. If it is not, there is another way of implementing it, where it will be.

我个人的偏好是 SWT。我开始使用它,当时 Swing 太糟糕了。SWT“只是”位于本机窗口 API 之上的一层,因此用 SWT 编写的应用程序感觉就像本机编写的应用程序。这些也可以搞砸。任何 API 都不会受到不良开发人员的影响。根据我的经验,性能尽可能快。如果不是,则有另一种实现方式,即它会在哪里。

SWT's API is very low level which makes implementing basic stuff unexpectedly tedious, but fortunately most typical usecases can be solved with JFace, which improves the situation. And when you use the API for a while you'll accumulate your own util classes. You can become pretty fast in implementing SWT tools.

SWT 的 API 非常低级,这使得实现基本的东西出乎意料地乏味,但幸运的是,大多数典型用例都可以用 JFace 解决,从而改善了这种情况。当您使用 API 一段时间后,您将积累自己的 util 类。您可以很快地实现 SWT 工具。

Since SWT gives you only the basics, you need MigLayoutand Nebulawidgets to survive. You might like Glazed Lists.

由于 SWT 只为您提供基础知识,因此您需要MigLayoutNebula小部件才能生存。你可能喜欢Glazed Lists

Qt Jambi

Qt占碑

Actually I would have liked to include another option besides SWT and Swing for you: Qt Jambi. But Nokia gave up on this, and it is "maintained by an open source community" now. So I don't know about "not being obsolete in a few years".

实际上,除了 SWT 和 Swing 之外,我还想为您添加另一个选项:Qt Jambi。但诺基亚放弃了这一点,现在“由一个开源社区维护”。所以我不知道“几年内不会过时”。

Nevertheless I am excited by this ongoing discussion. Some people have written an SWT implementation using Qt Jambi as "native" API. They are trying to figure out how to contribute it. Having Qt as an option might enable your "single library which runs on all platforms" for SWT one day, though I wouldn't count on it anytime soon.

尽管如此,我对正在进行的讨论感到兴奋。有些人使用 Qt Jambi 作为“原生”API 编写了 SWT 实现。他们正试图弄清楚如何贡献它。有朝一日将 Qt 作为选项可能会为 SWT 启用“在所有平台上运行的单一库”,尽管我不会很快指望它。

But for me your requirement of "a single library" is not such a big issue. Use maven for your builds, add a few lines of configuration and you'll forget about this very soon.

但对我来说,你对“单一图书馆”的要求并不是什么大问题。使用 maven 进行构建,添加几行配置,您很快就会忘记这一点。

Swing

摇摆

I can't really compare SWT to Swing, since my experience with Swing is limitted. As a user I don't like most Swing applications, but I did see some beatiful ones.

我无法真正将 SWT 与 Swing 进行比较,因为我对 Swing 的经验有限。作为用户,我不喜欢大多数 Swing 应用程序,但我确实看到了一些漂亮的应用程序。

Nowadays the native look and feel of Swing apps got pretty good, but you won't fool a power-user. Also performance seems to be really good in new and well done Swing apps, but again, this is only from my limitted view as a user.

如今,Swing 应用程序的本机外观和感觉非常好,但您不会欺骗高级用户。此外,性能在新的和做得很好的 Swing 应用程序中似乎非常好,但同样,这只是我作为用户的有限观点。

Obviously there are more 3rd party extensions for Swing than for SWT - just do a Google search. (But then again, if you endure the pain of learning Eclipse RCP you'll get an huge, interesting infrastructure as well. That's not talking about widgets though, that's stuff like EMFor RAP. I am no Eclipse RCP person - I never had enough patience for that...)

显然,Swing 的第 3 方扩展比 SWT 多——只需在 Google 上搜索即可。(但话又说回来,如果你忍受学习 Eclipse RCP 的痛苦,你也会得到一个巨大的、有趣的基础设施。不过这不是在谈论小部件,而是像EMFRAP这样的东西。我不是 Eclipse RCP 人 - 我从来没有有足够的耐心...)

A really big advantage for Swing, if you like that stuff, is Matisse, the GUI builder of Netbeans. Qt has also a well done GUI builder by the way.

如果您喜欢这些东西,Swing 的一大优势是 Netbeans 的 GUI 构建器 Matisse。顺便说一下,Qt 也有一个做得很好的 GUI 构建器。

Summary

概括

If you plan for long term, I don't see more options than SWT or Swing for GUI development in Java. Both are good enough to satisfy most needs if you spend enough time. But they are not perfect. You'll always envy people using other languages for their widgets, implementation speed, tooling, ... If you are not bound to Java, you might even prefer Flash or Qt.

如果您有长远的打算,我认为在 Java 中进行 GUI 开发时,没有比 SWT 或 Swing 更多的选择了。如果您花足够的时间,两者都足以满足大多数需求。但它们并不完美。您总是会羡慕人们使用其他语言来制作小部件、实现速度、工具等……如果您不受 Java 的束缚,您甚至可能更喜欢 Flash 或 Qt。

回答by Istao

The answer is prefer swing, I think.

答案是更喜欢swing,我想。

  • since 1.4 there are big progress on awt (sun do that because java fx need awt, fortunately)
  • since 1.5 big progress in thread managment (SwingWorker and concurrents things)
  • swing is excellent, responsive (what the problem with developper fault ? ), native l&f, and so on
  • there are excellent libraries, like swingx, trident, etc, and platform, like netbeans.
  • 从 1.4 开始,awt 有了很大的进步(sun 这样做是因为 java fx 需要 awt,幸运的是)
  • 自 1.5 线程管理(SwingWorker 和并发事物)取得重大进展
  • Swing 非常出色,反应灵敏(开发人员错误有什么问题?),原生 l&f 等等
  • 有优秀的库,如swingx、trident 等,也有平台,如netbeans。

Of course it is a mature technology (a little old), but I know nothing else. It will be cobol of GUI development :-)

当然是成熟的技术(有点老),但其他的我一无所知。它将成为 GUI 开发的合作伙伴 :-)