Starting with versions of JavaFX - JavaFX and "development patterns"

I plan to start developing a desktop application, but so far, for me, desktop = swing. I did a little research on this and found that on some issues:

  • I found that there are many versions of JavaFX:

    • There is JavaFX 1.0, which people say is deprecated and deprecated;
    • There is JavaFX 2.X, which is very good;
    • And now JavaFX 8 (is that right?);

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

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

  • About development templates, in particular about creating a layout, I noticed that there are two ways to create layouts: simply encoding it in Java and creating XML files (FXML) with a Java class as a controller (More MVC), like a JSF application. Which one to choose? What are the pros and cons of each?

+6
source share
1 answer

Welcome to the JavaFX World

I'm not sure why you came across such a JavaFX 2.2 issue with JDK 1.8, because JDK 8 has JavaFX 8 and should be used by default.

Just for a quick introduction to JavaFX and how it differs from Swing. Follow the steps below:

  • Instead of following the rules of building a view / user interface in Java code and ruining function codes with representations, you get the ability to split a view with functionality using FXML , introduced in JavaFX 2.0 +
  • JavaFX has powerful CSS integration that allows you to decorate a view that was not available in Swing .
  • Development is faster because you are a SceneBuilder to support you.

For further differences from Swing and JavaFX, please follow (although the answers are old and a lot has changed. JavaFX has become bigger and better!

https://stackoverflow.com/questions/1318645/JavaFX-or-swing

JavaFX 2 vs. Swing for a clean Windows desktop

Difference between JavaFX 1+, 2+ and 8+

  • JavaFX 1+ was basically a scripting language called JavaFX script, which was very different from Java.
  • JavaFX 2.0 has changed the face of JavaFX. The entire JavaFX API is now available as a pure Java API. FXML was also introduced at this point in JavaFX!
  • JavaFX 8.0 leads to a new look for JavaFX, where JavaFX is accepted as an integral part of Java 8 .

Compatibility . All JavaFX applications correspond to direct correspondence , i.e. JavaFX 2.0+ is compatible with Java 7, 8 and higher. Although applications built using JavaFX 8 are not compatible with Java 7 .

JavaFX 1.3 support has been killed since Java 1.7.

Development Templates

  • JavaFX makes it possible to create your application using your choice, i.e. use an outdated method of constructing views using pure Java or use FXML .
  • JavaFX strictly follows the MVC pattern, sharing your view and its events. Views are created using FXML , and controllers are Java files.

From Oracle docs

From the perspective of the Model Representation Manager (MVC), the FXML file that contains the user interface description is the view. The controller is a Java class that optionally implements the Initializable class, which is declared by the controller for the FXML file. The model consists of domain objects defined on the Java side that you connect to the view through the controller.

For more information and pro for FXML , follow these steps:

What is the best way to program in javafx?

+23
source

Source: https://habr.com/ru/post/969433/


All Articles