Java Swing 还在使用吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2994304/
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
Is Java Swing still in use?
提问by Mark Szymanski
I am planning on making a Java Swing application and was wondering if Swing is still used or if it has been replaced with something else.
我正计划制作一个 Java Swing 应用程序,并想知道 Swing 是否仍在使用,或者是否已被其他东西取代。
Thanks in advance!
提前致谢!
采纳答案by Romain Hippeau
We still use it. Not everything is a web app, so far there have been some tentative replacements (such as SWT, which eclipse is written in)
SWT has a native layer that wraps the underlying calls to the native windowing layer. It only works for a limited set of platforms and of course requires some third party shared libraries. I would venture to say that there are far fewer SWT apps than Swing apps.
我们仍然使用它。并不是所有的东西都是一个 web 应用程序,到目前为止已经有一些试探性的替代品(例如 SWT,eclipse 就是用它编写的)
SWT 有一个原生层,它包装了对原生窗口层的底层调用。它仅适用于有限的一组平台,当然需要一些第三方共享库。我敢说,SWT 应用程序比 Swing 应用程序少得多。
回答by Betamoo
Swing is still in use.... but there is AWT!!
Swing 仍在使用中......但有 AWT !!
AWT:
AWT:
Pros:
优点:
- Speed: use of native peers speeds component performance.
- Look and Feel: AWT components more closely reflect the look and feel of the OS they run on.
- 速度:使用本机对等节点可加快组件性能。
- 外观和感觉:AWT 组件更接近地反映了它们运行的操作系统的外观和感觉。
Cons:
缺点:
- Portability: use of native peers creates platform specific limitations. Some components may not function at all on some platforms.
- Third Party Development: the majority of component makers, including Borland and Sun, base new component development on Swing components. There is a much smaller set of AWT components available, thus placing the burden on the programmer to create his or her own AWT-based components.
- Features: AWT components do not support features like icons and tool-tips.
- 可移植性:使用本机对等点会产生特定于平台的限制。某些组件在某些平台上可能根本不起作用。
- 第三方开发:大多数组件制造商,包括 Borland 和 Sun,都基于 Swing 组件开发新组件。有一组小得多的 AWT 组件可用,因此将创建他或她自己的基于 AWT 的组件的负担置于程序员身上。
- 特性:AWT 组件不支持图标和工具提示等特性。
Swing:
摇摆:
Pros:
优点:
- Portability: Pure Java design provides for fewer platform specific limitations.
- Behavior: Pure Java design allows for a greater range of behavior for Swing components since they are not limited by the native peers that AWT uses.
- Features: Swing supports a wider range of features like icons and pop-up tool-tips for components.
- Vendor Support: Swing development is more active. Sun puts much more energy into making Swing robust.
- Look and Feel: The pluggable look and feel lets you design a single set of GUI components that can automatically have the look and feel of any OS platform (Microsoft Windows, Solaris, Macintosh, etc.). It also makes it easier to make global changes to your Java programs that provide greater accessibility (like picking a hi-contrast color scheme or changing all the fonts in all dialogs, etc.).
- 可移植性:纯 Java 设计提供了更少的平台特定限制。
- 行为:纯 Java 设计允许 Swing 组件有更大范围的行为,因为它们不受 AWT 使用的本机对等体的限制。
- 功能:Swing 支持更广泛的功能,例如组件的图标和弹出工具提示。
- 供应商支持:Swing 开发更加活跃。Sun 投入了更多的精力来使 Swing 更加稳健。
- 外观:可插拔的外观让您可以设计一组 GUI 组件,这些组件可以自动具有任何操作系统平台(Microsoft Windows、Solaris、Macintosh 等)的外观和感觉。它还可以更轻松地对 Java 程序进行全局更改,以提供更高的可访问性(例如选择高对比度配色方案或更改所有对话框中的所有字体等)。
Cons:
缺点:
- Performance: Swing components are generally slower and buggier than AWT, due to both the fact that they are pure Java and to video issues on various platforms. Since Swing components handle their own painting (rather than using native API's like DirectX on Windows) you may run into graphical glitches.
- Look and Feel: Even when Swing components are set to use the look and feel of the OS they are run on, they may not look like their native counterparts.
- 性能:Swing 组件通常比 AWT 更慢、更容易出错,这是因为它们是纯 Java 以及各种平台上的视频问题。由于 Swing 组件处理它们自己的绘画(而不是使用像 Windows 上的 DirectX 这样的本机 API),您可能会遇到图形故障。
- 外观和感觉:即使将 Swing 组件设置为使用它们所运行的操作系统的外观和感觉,它们看起来也可能与原生组件不同。
回答by Joe Phillips
Yes it is still in use.
是的,它仍在使用中。
Update: It's still in use.
更新:它仍在使用中。
回答by James Anderson
Swing is still there and well supported.
Swing 仍然存在并且得到了很好的支持。
Most of the reasons why people hated swing when it first came out are no longer valid simply because of Moores Law, along with improved JVMs. Swing apps no loger feel jerky and unrepsonsive and an accumulation of minor improvements result in a more professional looking GUI.
人们在第一次出现时讨厌 Swing 的大多数原因不再仅仅因为摩尔定律以及改进的 JVM 就成立。Swing 应用程序不会让日志记录器感到生涩和反应迟钝,并且微小改进的积累会产生更专业的 GUI。
Its also worth looking at the "groovy/swing" combination for rapid development and prototyping.
它还值得关注“groovy/swing”组合以进行快速开发和原型设计。
回答by Ivan Nikitin
Yes. Roughly 1 out of 120 questionson StackOverflow is about Swing
.
是的。StackOverflow 上的 120 个问题中大约有1 个是关于 Swing 的
。
回答by JavaMan
Yes, it still is in use. The library is still part of the JRE, and will probably be that way for the future. There are other options though. For instance, you may want to look at JavaFX if you need a rich UI; or using SWT in your application. Maybe you want some kind of 3D effects, and you need to look into a 3D engine like jpct or the jmonkeyengine. Java has progressed somewhat since the software Swing world.
是的,它仍在使用中。该库仍然是 JRE 的一部分,未来可能会如此。不过还有其他选择。例如,如果您需要丰富的 UI,您可能想查看 JavaFX;或在您的应用程序中使用 SWT。也许您想要某种 3D 效果,并且您需要研究像 jpct 或 jmonkeyengine 这样的 3D 引擎。自软件 Swing 世界以来,Java 取得了一些进展。
回答by stacker
Although swing is still in use, I would rather chose Eclipse RCPas a platform for desktop applications, since it also provides a huge amount of plugins.
虽然swing仍在使用,但我更愿意选择Eclipse RCP作为桌面应用程序的平台,因为它也提供了大量的插件。
回答by Joe Zitzelberger
Swing is still the preferred way to build heavy-weight, e.g. "Desktop" applications, in Java. If your code is running in a web browser, you will likely use other things. But for freestanding desktop apps, it is quite excellent and in wide use.
Swing 仍然是用 Java 构建重量级应用程序(例如“桌面”应用程序)的首选方法。如果您的代码在 Web 浏览器中运行,您可能会使用其他东西。但是对于独立的桌面应用程序来说,它非常出色并且被广泛使用。
回答by Jamie McIlroy
Yes, it's still in use. Takes while to get used to but once you have it, it's a pretty nice framework for writing applications. Have a look at Webstart for deploying your application. Also a bit of a clunker to start with but really handy when you're comfortable
是的,它仍在使用中。需要一段时间才能习惯,但是一旦掌握了它,它就是一个非常好的编写应用程序的框架。查看用于部署应用程序的 Webstart。开始时也有点笨拙,但当你感到舒服时真的很方便
回答by TheLQ
For desktop programs, yes, Swing is heavily in use. However there are many alternatives because alot of people think that Swing is heavily verbose and hard to work with. JavaFX is worth taking a look at
对于桌面程序,是的,Swing 被大量使用。然而,有很多替代方案,因为很多人认为 Swing 非常冗长且难以使用。JavaFX 值得一看

