简体   繁体   English

Java桌面应用程序框架与JavaFX

[英]Java desktop application frameworks vs. JavaFX

There are a lot of Java "application frameworks" such as those listed in http://pivot.apache.org/demos/ which pretty much all use Swing as the GUI toolkit, or in the case of Eclipse, SWT. 有许多Java“应用程序框架”,例如http://pivot.apache.org/demos/中列出的那些,几乎都使用Swing作为GUI工具包,或者在Eclipse的情况下使用SWT。

However I have not seen any obvious frameworks for JavaFX. 但是我没有看到任何明显的JavaFX框架。 Why is this? 为什么是这样?

If looking at the "Hollywood Principle", where the framework calls you, I would think JavaFX already does this, but then I'm confused because it would seem Swing and JavaFX do mostly the same role, which is as the GUI layer. 如果看看框架调用你的“好莱坞原则”,我会认为JavaFX已经这样做了,但后来我很困惑,因为看起来Swing和JavaFX的作用大致相同,就像GUI层一样。 But they both do event loops and callbacks/events/observer patterns, etc. 但它们都执行事件循环和回调/事件/观察者模式等。

Does merely implementing an event loop and calling your event handler not qualify as an "application framework"? 仅仅实现一个事件循环并调用您的事件处理程序不符合“应用程序框架”的条件吗?

If not, are there any frameworks based on JavaFX directly (rather than embedding JavaFX in a Swing control)? 如果没有,是否有任何基于JavaFX的框架(而不是在Swing控件中嵌入JavaFX)? What would such a framework provide that JavaFX standalone does not? 这样的框架会为JavaFX独立提供什么?

Sorry for the "obviousness" of this question, but it's not obvious to me. 对于这个问题的“显而易见性”感到抱歉,但这对我来说并不明显。

thanks. 谢谢。

There are plenty of them looks like your research has not been very thorough 有很多看起来你的研究还不是很彻底

As I'm the author of e(fx)clipse I'm biased but I know first hand that it is used on (big) commercial projects 由于我是e(fx)clipse的作者,我有偏见但我知道它用于(大)商业项目

In my opinion, Swing, JavaFX and also SWT are graphical toolkit, providing a set of basic widgets. 在我看来,Swing,JavaFX和SWT都是图形工具包,提供了一组基本的小部件。 There are not "Application" frameworks because their main goal is to display an User Interface. 没有“应用程序”框架,因为它们的主要目标是显示用户界面。 But you can use them to build an application without any other library by using basic features. 但是,通过使用基本功能,您可以使用它们来构建没有任何其他库的应用程序。

A good sample application can be found here: https://github.com/angelicalleite/museuid 可以在这里找到一个很好的示例应用程序: https//github.com/angelicalleite/museuid

It looks really nice with data picked from a mysql database, but if you read carefully the source code you can notice that all SQL queries are performed within the UI thread which will slow down the UI responsiveness. 从mysql数据库中挑选数据看起来非常不错,但如果仔细阅读源代码,您会注意到所有SQL查询都在UI线程中执行,这会降低UI响应速度。

This is one of the reason you should use an Application Framework. 这是您应该使用应用程序框架的原因之一。 Their goals vary and are numerous but they all are dedicated to ease your application development by keeping complex things (like multithreading, messaging) out of your application code. 他们的目标各不相同,而且数量众多,但它们都致力于通过从应用程序代码中保留复杂的东西(如多线程,消息传递)来简化应用程序的开发。

Your choice shall be done according to your personal convictions about architecture and dependencies you want to use (or don't). 您的选择应根据您对要使用(或不使用)的体系结构和依赖关系的个人信念进行。

I'm the author of JRebirth (disclaimer), but I sometimes have a look on other frameworks, so you can make your choice by asking yourself some basic questions: 我是JRebirth(免责声明)的作者,但我有时会看看其他框架,所以你可以通过问自己一些基本问题做出选择:

Do you want/need OSGI support ? 您想要/需要OSGI支持吗?

=> Yes efxclipse, DromblerFX, DEMUX =>是efxclipse,DromblerFX,DEMUX

=> No JRebirth,JacpFX, DataFX, griffonFX, afterburner.fx =>没有JRebirth,JacpFX,DataFX,griffonFX,afterburner.fx

Do you want a minimalist framework? 你想要一个极简主义的框架吗?

=> Yes afterburner.fx =>是的afterburner.fx

Do you want/need event messaging? 您想要/需要事件消息吗?

Do you want to share code? 你想分享代码吗?

Do you want modularization? 你想要模块化吗?

Do you require Java 7 support ? 您需要Java 7支持吗?

How do you want to manage your application threads. 您希望如何管理应用程序线程。

I certainly forget a lot of questions. 我当然忘记了很多问题。

In fact you SHOULD use one of these Application Framework (building your own will be time-consuming), it will defintely speed up your developments and secure them, the remaining questions are : 事实上,您应该使用这些应用程序框架中的一个(构建您自己的将非常耗时),它将彻底加快您的开发并保护它们,其余的问题是:

  • What AF will fit your needs ? 什么AF适合您的需求?
  • What AF will be convenient to use for you and your team ? 什么AF可以方便您和您的团队使用?

Choosing an AF using patterns you don't like could be painful, in any case you can contribute to any available AF because they are all open sourced. 使用您不喜欢的模式选择AF可能会很痛苦,无论如何您可以为任何可用的AF做出贡献,因为它们都是开源的。

Hope it helps, 希望能帮助到你,

The simple answer to this is: JavaFX is much younger than Swing - at least as a standard JDK library. 对此的简单回答是:JavaFX比Swing年轻得多 - 至少作为标准的JDK库。 As a matter of fact, it only became a "real" standard part with Java 8. If you check the history , you see the following facts: 事实上,它只是成为Java 8的“真正”标准部分。如果查看历史记录 ,您会看到以下事实:

  • Before JavaFX 2 (released 2011), developers needed to learn a scripting language. 在JavaFX 2(2011年发布)之前,开发人员需要学习脚本语言。
  • Also before JavaFX 2, the implementation aimed at being platform independent and therefore made no use of system-specific resources which can make a big difference in graphics and animation. 此外,在JavaFX 2之前,该实现旨在独立于平台,因此不使用可以在图形和动画方面产生重大影响的系统特定资源。

Read through it, and you'll find some more interesting details which can be summed up in that probably most developers have only been "seriously" noticing JavaFX within the last 5 years or so. 仔细阅读它,你会发现一些更有趣的细节,可以概括为大多数开发人员在过去5年左右才“认真地”注意到JavaFX。 Swing goes back much further (especially as being baked into the standard Java Runtime Environment), so naturally there are far more libraries aimed at Swing than at FX. Swing可以追溯得更远(尤其是在标准的Java运行时环境中),因此自然会有更多针对Swing的库而不是FX。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM