本文介绍了从JavaFX开始 - JavaFX版本和“开发模式”问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算开始开发桌面应用程序,但直到现在,对我来说,desktop = swing。我做了一些关于它的研究并发现自己有一些问题:

I am planning on starting the development of a desktop app, but until now, for me, desktop = swing. I did a little research about it and found myself under some questions:


  1. 我发现有很多JavaFX版本:

  1. I found that there are a lot of JavaFX versions:


  • 人们说JavaFX 1.0已经陈旧且过时;

  • 有JavaFX 2。 X非常好;

  • 现在JavaFX 8(这是正确的吗?);

但即使最新的NetBeans IDE版本(8.0)与JDK 8(1.8.0),当我创建一个JavaFX应用程序时,它开始使用JavaFX 2.2 - JavaFX 8真的是一个新的JavaFX版本或人们说它只是因为他们将JavaFX 2.X与JDK 8一起使用?

But even with the most recent NetBeans IDE version (8.0) with JDK 8 (1.8.0), when I create a JavaFX application, it starts using JavaFX 2.2 – Is JavaFX 8 really a new JavaFX version or people say it just because they use JavaFX 2.X with JDK 8?

关于版本的另一个问题,在JavaFX版本X中开发的应用程序是否与更高版本兼容?就像swing应用程序一样,如果你在Java 5中开发了一个应用程序,它甚至可以在Java 8上运行。

Another question about versions, will applications developed in a version X of JavaFX be compatible with higher versions? Just like a swing application, where if you developed an application in Java 5, it would work even on Java 8.

关于开发模式,更具体地说是关于布局创建时,我注意到有两种创建布局的方法:只需用Java编写代码,然后用Java类作为控制器创建XML文件(FXML)(更多MVC方法),就像JSF应用程序一样。我应该选择哪一个?每个人的利弊是什么?

About development patterns, more specifically about layout creation, I noticed there are two ways for creating layouts: By just coding it in Java, and by creating XML files (FXML) with a Java Class as a controller (More MVC approach) just like a JSF application. Which one should I choose? What are the pros and cons of each one?


推荐答案

欢迎来到JavaFX的世界



我不确定你为什么要面对JDK 1.8这样的JavaFX 2.2问题,因为JDK 8里面有JavaFX 8,它必须是默认情况下使用。

只是简单介绍一下JavaFX以及它与Swing的不同之处。请遵循以下几点:

Just to give a quick introduction on JavaFX and how it is different from Swing. Please follow the following points:


  1. 而不是遵循在Java代码中构建视图/ UI并使用视图弄乱功能代码的遗留问题,您有机会使用

  2. JavaFX具有强大的 CSS 集成功能,允许您装饰视图,强大>在Swing中缺席。

  3. 开发速度更快,因为你有支持你。

  1. Instead of following the legacy of building the view/UI in Java code and messing your functional codes with views, you get the opportunity of separating the view with the functionality using the FXML introduced in JavaFX 2.0+
  2. JavaFX has powerful CSS integration which allows you to decorate the view, which was absent in Swing.
  3. The development is quicker, as you have SceneBuilder to back you.

关于Swing和JavaFX的更多差异,请关注(虽然答案很老,但很多事情都发生了变化。 JavaFX变得更大更好!

For more differences on Swing and JavaFX please follow (though the answers are old and many things have changed. JavaFX has become bigger and better!)

JavaFX 1 +,2 +和8 +


  1. JavaFX 1+基本上是一种称为JavaFX脚本的脚本语言,它与Java语言非常不同。

  2. JavaFX 2.0改变了JavaFX的面貌。所有JavaFX API现在都可以作为纯Java API使用。在JavaFX的这个阶段也引入了FXML!

  3. JavaFX 8.0引领了JavaFX的新面貌,其中JavaFX被接受为 Java 8 的组成部分。

  1. JavaFX 1+ was basically a scripting language called as JavaFX script, which was very different from the Java language.
  2. JavaFX 2.0 changed the face of JavaFX. All of JavaFX API was now available as pure Java API. FXML was also introduced during this phase in JavaFX!
  3. JavaFX 8.0 leads to a new face of JavaFX where JavaFX is accepted as an integral part of Java 8.

兼容性 - 所有JavaFX应用程序向前合规性,即 JavaFX 2.0+与Java 7,8及以上版本兼容。虽然使用 JavaFX 8创建的应用程序与Java 7 不兼容。

Compatibility - All JavaFX application is forward compliance, i.e. JavaFX 2.0+ is compatible with Java 7, 8 and above. Though applications made using JavaFX 8 is not compatible with Java 7.

开发模式


  1. JavaFX提供了使用您的选择构建应用程序的机会 - 即使用遗留方法使用纯Java构建视图或使用 FXML

  2. JavaFX严格遵循MVC模式,将视图及其事件分开。视图使用 FXML 创建,控制器是Java文件。

  1. JavaFX gives a chance to build your application using your choice – i.e. use the legacy method of building the view using pure Java or use FXML.
  2. JavaFX strictly follows MVC pattern, separating your view and its events. The views are created using FXML and the controllers are Java files.

从模型视图控制器(MVC)的角度来看,包含用户界面描述的FXML文件是视图。控制器是一个Java类,可选地实现Initializable类,该类被声明为FXML文件的控制器。该模型由在Java端定义的域对象组成,您通过控制器连接到视图。

更多信息和 pro's对于FXML ,请遵循:

这篇关于从JavaFX开始 - JavaFX版本和“开发模式”问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 01:28