用于 Java 桌面应用程序的 JavaFX、Swing 或 Flex

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

JavaFX, Swing, or Flex for Java Desktop Applications

javaapache-flexswingdesktopjavafx

提问by Jeff Storey

Most of the desktop application development I do is in Swing, and I'm curious to hear people's thoughts on using JavaFX and/or Adobe Flex for building desktop applications. Have you had success building desktop apps with these? Or would you stick with Swing for now and use tools to help make Swing development more productive?

我所做的大部分桌面应用程序开发都是在 Swing 中进行的,我很想知道人们对使用 JavaFX 和/或 Adob​​e Flex 构建桌面应用程序的想法。您是否成功地使用这些构建桌面应用程序?或者您现在会坚持使用 Swing 并使用工具来帮助提高 Swing 开发的效率吗?

回答by CarlG

If you're making desktop apps, I'd stick to Swing. JavaFX/Flex/Silverlight would be more appropriate for RIA - rich internet apps. Although I'd argue that none of them would be a choice for the long term - looks to me like HTML5/CSS3/Ajax are winning the day, but thats a pretty subjective area. But for desktop apps - I'm a big fan of Swing (also Java Web Start is a very underrated technology)

如果您要制作桌面应用程序,我会坚持使用 Swing。JavaFX/Flex/Silverlight 更适合 RIA - 丰富的互联网应用程序。尽管我认为从长远来看它们都不是一个选择 - 在我看来 HTML5/CSS3/Ajax 赢得了这一天,但这是一个非常主观的领域。但是对于桌面应用程序 - 我是 Swing 的忠实粉丝(Java Web Start 也是一种非常被低估的技术)

回答by SirFabel

I would say that JavaFX can be seen as a kind of extension of Swing with a new way of developing a Java GUI by using a declarative programming language: the JavaFX Script. JavaFX Script code looks exactly like a JSON script, unlike Adobe Flex or Microsoft Silverlight which uses an XML syntax.

我想说的是,JavaFX 可以被视为 Swing 的一种扩展,它采用了一种使用声明式编程语言 JavaFX Script 来开发 Java GUI 的新方法。JavaFX Script 代码看起来完全像 JSON 脚本,不像 Adob​​e Flex 或 Microsoft Silverlight 使用 XML 语法。

JavaFX Script can interface with Java and therefore can call Swing components easily. It's really a new generation of GUI API, like Swing was for AWT: nice graphical components, new easy ways to manage layouts, really nice features to build dynamic interfaces: bindings, timers (to build animations), etc. Have a look here: http://www.javafx.com/samples/and to the tutorials and see how fast you can build a kind of Google Picasa application... The API even contains some tools to use easily web services: you can find plenty of samples of GUI built in JavaFX connected to some public web services (like a Weather Forecast tool).

JavaFX Script 可以与 Java 交互,因此可以轻松调用 Swing 组件。它真的是新一代的 GUI API,就像 Swing 用于 AWT:漂亮的图形组件、管理布局的新方法、构建动态界面的非常好的功能:绑定、计时器(构建动画)等。看看这里:http://www.javafx.com/samples/和教程,看看您可以多快地构建一种 Google Picasa 应用程序... API 甚至包含一些工具来轻松使用网络服务:您可以找到大量示例在 JavaFX 中构建的 GUI 连接到一些公共 Web 服务(如天气预报工具)。

And the best... is the deployment part. You can embed your application within an html page, like an applet, and the user can drag and drop the application to her/his desktop to use it whenever she/he wants (without returning to its browser)!

最好的......是部署部分。您可以将您的应用程序嵌入到 html 页面中,就像小程序一样,用户可以将应用程序拖放到她/他的桌面,以便随时使用它(无需返回浏览器)!

Really, I think JavaFX, at its early stage though (v1.2), is a really good tool and represents the first step for Java toward the next generation of applications: the Rich Internet Applications (RIA).

确实,我认为 JavaFX 在其早期阶段 (v1.2) 是一个非常好的工具,代表了 Java 迈向下一代应用程序的第一步:富 Internet 应用程序 (RIA)。

回答by Pedro Estrada

Java Swing is an established and mature technology for desktop development. You'll be able to find lots of information online and plenty of sample programs. With that said, however, you might want to consider Adobe AIR. AIR is basically a runtime that lets you run your Flex apps on the desktop, and gives them access to local resources such as the file system. I've written Java Swing apps for 10 years and I am amazed at how much more productive I am using Flex/Adobe AIR. One nice aspect of Flex is that you can create your GUIs declaritively, much like how you use HTML to declare the layout of a webpage. It's a much more concise way to specify a GUI, and much faster and easier to maintain than the reams of Java Swing code you need to do the same thing. I wouldn't recommend JavaFX since it is so late to the party and hasn't really gotten with mainstream developers.

Java Swing 是一种成熟的桌面开发技术。您将能够在网上找到大量信息和大量示例程序。但是,话虽如此,您可能需要考虑 Adob​​e AIR。AIR 基本上是一个运行时,可让您在桌面上运行 Flex 应用程序,并允许它们访问本地资源,例如文件系统。我已经编写 Java Swing 应用程序 10 年了,我对使用 Flex/Adobe AIR 的工作效率感到惊讶。Flex 的一个优点是您可以声明性地创建 GUI,就像您如何使用 HTML 来声明网页的布局一样。这是指定 GUI 的更简洁的方法,并且比执行相同操作所需的大量 Java Swing 代码更快、更容易维护。我不会推荐 JavaFX,因为聚会太晚了,而且还没有

回答by viren

Please read the about this, write extremely lightweight swing applications and with the same code base move it to web.

请阅读有关内容的内容,编写极其轻量级的 Swing 应用程序,并使用相同的代码库将其移至网络。

回答by James Ward

You should try them all and see which one fits best with your requirements. If you want to see what you can do with Flex and how to do it then check out Tour de Flex.

您应该尝试所有这些,看看哪一个最适合您的要求。如果您想了解 Flex 可以做什么以及如何做,请查看Tour de Flex

Some of the advantages of Flex are that it is mature (over 5 years old now) and a significant area of investment for Adobe. You can also find numerous examples of AIR apps built with Flex in the Adobe AIR Marketplace.

Flex 的一些优点是它已经成熟(现在已有 5 年以上的历史)并且是 Adob​​e 的重要投资领域。您还可以在Adobe AIR Marketplace 中找到大量使用 Flex 构建的 AIR 应用程序示例。

回答by glebm

Swing can look good with Substance L&F.

使用 Substance L&F,Swing 看起来不错。

However, if you are developing alone (as opposed to with a team), trying JavaFX might be a good idea.

但是,如果您是单独开发(而不是与团队一起开发),尝试 JavaFX 可能是个好主意。

回答by Neil

I had evaluated these for desktop application and finally desided to go for JavaFx . This have very good media libraryand hardware accelerated graphics and media capabilities . With Jdk 7 update 6 onwards contains JavaFx totally I integrated no separate installation is required . Java swing is very good technology and will be continued but I see JavaFx is the future for GUI and Internet application to some extent. Biggest advantage for me was that JavaFx app could be converted to exe files with native packaging

我已经为桌面应用程序评估了这些,最后决定选择 JavaFx。这具有非常好的媒体和硬件加速图形和媒体功能。随着 Jdk 7 update 6 开始包含 JavaFx,我完全集成,不需要单独安装。Java Swing 是一项非常好的技术并将继续使用,但我认为 JavaFx 在某种程度上是 GUI 和 Internet 应用程序的未来。对我来说最大的优势是 JavaFx 应用程序可以转换为本地打包的exe 文件

Also try scenebuilder for drag and drop component designer

还可以尝试用于拖放组件设计器的场景构建器

回答by powelljf3

I feel that I do not have enough information to answer this question. There are many applications in which an AIR approach is a better choice, other applications use other technologies better. I am primarily an AS3/Flex developer, but I know there are many instances where one of the Java platforms is a better choice. Now that Flex is no longer an Adobe product but rather a Apache product, it will either improve the product as the users will create the roadmap, or kill it off completely.

我觉得我没有足够的信息来回答这个问题。在许多应用程序中,AIR 方法是更好的选择,其他应用程序更好地使用其他技术。我主要是一名 AS3/Flex 开发人员,但我知道在很多情况下,Java 平台之一是更好的选择。现在 Flex 不再是 Adob​​e 产品,而是 Apache 产品,它要么在用户创建路线图时改进产品,要么完全取消它。