有相当多的java gui框架,但目前公认的框架选择是什么?

以下是我对不同框架的理解,如果错了请指正。这是一个定义非常松散的问题集,但我仍然认为它对任何考虑创建富gui应用程序的人都是有价值的。


AWT

是秋千的基础,它的性能很好,但缺乏先进的组件。如果您打算创建富应用程序,AWT可能不是合适的方法。但是对于不需要富用户界面的小型gui应用程序。这可能非常适合,因为它是一个经过验证的框架。


摇摆不定的

基于前面所述的AWT。在它的婴儿期,它被认为是缓慢和错误的,并导致IBM为Eclipse创建SWT。但是对于Java 5(或6?)Swing成为构建新应用程序的首选框架。Swing有很多丰富的组件,但在某些方面仍然缺乏。一个例子是,没有一个功能完整的TreeTable组件可以进行排序和过滤/搜索。


SWT

Created by IBM for Eclipse, they seemed to think that Swing was not suited for Eclipse at the time. By itself is pretty low-level, and it uses the platform's native widgets through JNI. It is not related to Swing and AWT at all. Their API is however somewhat clunky and not intuitive. They do have some advanced component's like a TreeTable. (but i don't think they support sorting and filtering out of the box). SWT uses some native bindings (through JNI?) and the rant on the internet is that this framework should not be used in today's projects. (why not?)


摇摆X

它基于Swing,其任务是为Swing创建丰富的组件。仍在开发中。(不过不是很活跃。)有一个非常好的组件集,比如TreeTable。但据我所知,TreeTable不支持过滤和排序。但是它支持高亮搜索。

注意,SwingX是组件(AFAIU),它是扩展或扩展 现有Swing组件的组合


JGoodies

一个我一无所知的框架…它的优点和缺点是什么?Jgoodies和其他人的区别是什么?

JGoodies OTOH是关于PLAFs和布局。


JavaFX

Java/Oracle的最新旗舰产品。有望成为开发富桌面或web应用程序的事实标准。


Apache主

它使用Java2D渲染UI,从而最大限度地减少Swing和AWT遗留的影响(IMO,臃肿)。(@Augustus Thoo)

它的主要关注点似乎是RIA(富互联网应用程序),但它似乎也可以应用于桌面应用程序。作为个人评论,看起来很有趣!我特别喜欢这是一个apache项目。

https://cwiki.apache.org/PIVOT/frequently-asked-questions-faq.html


Qt占比

本机qt库的java包装器,用c/c++编写。非常强大,被广泛使用和接受。有很多GUI组件和一个易于使用的API。

http://qt-jambi.org/


所以,试着总结一下我的问题:

假设我今天想用Java创建一个桌面应用程序,其中涉及很多高级组件,我应该选择什么?,为什么?

在这些框架中,哪些应该被认为是过时的,哪些应该被认为是遥远未来的框架?

什么是当今的标准框架,您使用哪些工具来创建java gui应用程序?


我可能会后悔问这个问题,但无论如何我会尝试一下:

c# /。Net据说有一套非常好的易于使用的组件,可以在任何可能的方向上进行弯曲。在某种程度上研究了不同的java框架之后,我似乎不能对java说同样的话。为什么会这样?为什么java(世界上使用最广泛的编程语言)没有相同的GUI组件集?

这只是java已经基于他们的gui组件在一个低得多的级别,它是有可能编写所有这些高级组件,我正在寻找,但你必须做很多,如果不是所有的工作自己?


我想推荐另一个框架:Apache Pivot http://pivot.apache.org/。

我简单地试用了一下,并被它作为一个RIA(富互联网应用程序)框架在Flash中所提供的功能所打动。

它使用Java2D渲染UI,从而最大限度地减少Swing和AWT遗留的影响(IMO,臃肿)。


我个人的观点是:与NetBeans平台一起使用Swing。

如果你需要高级组件(比NetBeans提供的更多),你可以很容易地集成SwingX,没有问题(或JGoodies),因为NetBeans平台完全基于Swing。

如果没有一个基于底层UI框架的良好平台,我不会启动一个大型桌面应用程序(或一个即将变得大型的桌面应用程序)。

另一种选择是SWT和Eclipse RCP,但是将“纯”Swing组件集成到这样的应用程序中比较困难(尽管不是不可能)。

NetBeans平台的学习曲线有点陡峭(尽管我想对于Eclipse也是如此),但是我强烈推荐一些好书。


你忘记了Java桌面应用基于JSR296作为内置Swing框架在NetBeans

除了AWT和JavaFX,你所描述的所有框架都是基于Swing的,如果你从Swing开始,那么你就会(清楚地)理解所有这些Swing的(基于框架)。

ATW, SWT (Eclipse), Java桌面应用(Netbeans), SwingX, JGoodies

所有这些框架(我对JGoodies了解不多)包括JavaFX都没有很长时间的进展,Swing的很多基于框架都停止了,如果没有的话,那就没有最新的版本了

这只是我的观点——其中最好的是SwingX,但需要对Swing有最深入的了解,

Swing基于框架的外观和感觉


在我参与的桌面应用程序中,我对Swing非常满意。但是,我同意您关于Swing不提供高级组件的观点。在这些情况下,我所做的是使用JIDE。它不是免费的,但也不是那么贵,它为你提供了更多的工具。具体来说,它们确实提供了可过滤的TreeTable。


我会选择Swing。对于布局,我会使用JGoodies表单布局。表单布局白皮书值得我们研究一下——http://www.jgoodies.com/freeware/forms/

另外,如果你要开始开发一个巨大的桌面应用程序,你肯定需要一个框架。其他人则指出了netbeans框架。我不太喜欢它,所以写了一个新的,我们现在在我的公司使用。我已经把它放到sourceforge上了,但是没有时间去记录它。下面是浏览代码的链接:

http://swingobj.svn.sourceforge.net/viewvc/swingobj/

该展示应该告诉你如何做一个简单的登录实际上..

如果你有任何问题,请告诉我,我可以帮忙。


SWT by itself is pretty low-level, and it uses the platform's native widgets through JNI. It is not related to Swing and AWT at all. The Eclipse IDE and all Eclipse-based Rich Client Applications, like the Vuze BitTorrent client, are built using SWT. Also, if you are developing Eclipse plugins, you will typically use SWT. I have been developing Eclipse-based applications and plugins for almost 5 years now, so I'm clearly biased. However, I also have extensive experience in working with SWT and the JFace UI toolkit, which is built on top of it. I have found JFace to be very rich and powerful; in some cases it might even be the main reason for choosing SWT. It enables you to whip up a working UI quite quickly, as long as it is IDE-like (with tables, trees, native controls, etc). Of course you can integrate your custom controls as well, but that takes some extra effort.


Swing + SwingX + Miglayout是我的选择组合。Miglayout比swing简单得多,swing有200种不同的布局管理器,而且功能更强大。此外,它还为您提供了“调试”布局的能力,这在创建复杂的布局时尤其方便。


另一种选择是使用Qt Jambi。它几乎拥有Qt的所有优点(很多组件,良好的文档,易于使用),而没有c++的麻烦。我在3-4年前的一个小项目中使用过它,那时它已经很成熟了。

您可能想在这里看到关于Swing与Qt的讨论。


决策树:

Frameworks like Qt and SWT need native DLLs. So you have to ask yourself: Are all necessary platforms supported? Can you package the native DLLs with your app? See here, how to do this for SWT. If you have a choice here, you should prefer Qt over SWT. Qt has been developed by people who understand UI and the desktop while SWT has been developed out of necessity to make Eclipse faster. It's more a performance patch for Java 1.4 than a UI framework. Without JFace, you're missing many major UI components or very important features of UI components (like filtering on tables). If SWT is missing a feature that you need, the framework is somewhat hostile to extending it. For example, you can't extend any class in it (the classes aren't final, they just throw exceptions when the package of this.getClass() isn't org.eclipse.swt and you can't add new classes in that package because it's signed). If you need a native, pure Java solution, that leaves you with the rest. Let's start with AWT, Swing, SwingX - the Swing way. AWT is outdated. Swing is outdated (maybe less so but not much work has been done on Swing for the past 10 years). You could argue that Swing was good to begin with but we all know that code rots. And that's especially true for UIs today. That leaves you with SwingX. After a longer period of slow progress, development has picked up again. The major drawback with Swing is that it hangs on to some old ideas which very kind of bleeding edge 15 years ago but which feel "clumsy" today. For example, the table views do support filtering and sorting but you still have to configure this. You'll have to write a lot of boiler plate code just to get a decent UI that feels modern. Another weak area is theming. As of today, there are a lot of themes around. See here for a top 10. But some are slow, some are buggy, some are incomplete. I hate it when I write a UI and users complain that something doesn't work for them because they selected an odd theme. JGoodies is another layer on top of Swing, like SwingX. It tries to make Swing more pleasant to use. The web site looks great. Let's have a look at the tutorial ... hm ... still searching ... hang on. It seems that there is no documentation on the web site at all. Google to the rescue. Nope, no useful tutorials at all. I'm not feeling confident with a UI framework that tries so hard to hide the documentation from potential new fans. That doesn't mean JGoodies is bad; I just couldn't find anything good to say about it but that it looks nice. JavaFX. Great, stylish. Support is there but I feel it's more of a shiny toy than a serious UI framework. This feeling roots in the lack of complex UI components like tree tables. There is a webkit-based component to display HTML. When it was introduced, my first thought was "five years too late." If your aim is a nice app for phones or web sites, good. If your aim is professional desktop application, make sure it delivers what you need. Pivot. First time I heard about it. It's basically a new UI framework based on Java2D. So I gave it a try yesterday. No Swing, just tiny bit of AWT (new Font(...)). My first impression was a nice one. There is an extensive documentation that helps you getting started. Most of the examples come with live demos (Note: You must have Java enabled in your web browser; this is a security risk) in the web page, so you can see the code and the resulting application side by side. In my experience, more effort goes into code than into documentation. By looking at the Pivot docs, a lot of effort must have went into the code. Note that there is currently a bug which prevents some of the examples to work (PIVOT-858) in your browser. My second impression of Pivot is that it's easy to use. When I ran into a problem, I could usually solve it quickly by looking at an example. I'm missing a reference of all the styles which each component supports, though. As with JavaFX, it's missing some higher level components like a tree table component (PIVOT-306). I didn't try lazy loading with the table view. My impression is that if the underlying model uses lazy loading, then that's enough. Promising. If you can, give it a try.