有相当多的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组件在一个低得多的级别,它是有可能编写所有这些高级组件,我正在寻找,但你必须做很多,如果不是所有的工作自己?
决策树:
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.