It all started with swing. It seems everything is clear there: you create classes, you make their interaction, you hang listeners on the buttons ... Then I decided to quickly rewrite the program in JavaFX.

First read the 3 chapters on JavaFX in Schild's book "Java 8. Complete Guide." After that, I started reading "introducing javafx 8 programming" by the same author. It seemed that managing JavaFX is about the same as Swing. BUT ... During the development process, a huge number of questions arise that were not in Swing.

For example, why in IntelliJ Idea there is a point of creating a JavaFX project, if you can inherit any class from Application? How to create applications using FXML? How is the fxml file associated with my classes? What are JavaFX applications going to do? Should I use SceneBuilder? How to use MVC model? What is going on ?

In general, in spite of the poem above, the question is simple - how to start a JavaFX project and how to build it in the future so that there are minimum problems? Are there any sources that can answer my questions?

  • 2
    As a start, read this tutorial. He will not answer all the questions, but he will arrange the remaining ... - Peter Slusar
  • If you are just starting out, do not immediately start using FXML, first practice without it, and on JavaFX, read "Learn JavaFX 8" by Kishori Sharan, there everything is more detailed and more intelligibly written. - arachnoden
  • Excellent comment, be sure to look at the book. - faoxis
  • I personally view the JavaFX project as a simple Java project. Those. I create a hierarchy of modules and collect it using gradle. I use IntelliJ Idea as a tool for working with Java code. Idea does not even know what I am doing the GUI application. Those. I do not use SceneBuilder. I also completely abandoned FXML. On the other hand, it turns out quite flexibly and easily expands. Here is an example . Quite an interesting topic, so if you ask more specific questions, you will get a useful experience. - Stanley Wintergreen

1 answer 1

Well. I powdered your brains, I'll explain to you.

  1. In the idea as in all normal IDE there are applications for applications. Yes, you can inherit any class from Application. If in the preparation of an idea this is done with the main class, it still does not forbid you to do differently.
  2. What is the application with FXML. It can be compared with the website:
    1. FXML is a markup file. It describes the interface elements: their names, location, primary settings, as well as the names of the methods that will be invoked with a particular action.
    2. It also binds to the controller . This is such a link between the logic of your application and the interface. There are declared interface elements objects with which you need to interact, as well as methods that work when working with your interface (such as eventHandlers for buttons and other things). In this case, you do not need to initialize and configure the interface elements in it. An instance of this class with all bindings and active content is created when loading fxml.
  3. JavaFX applications are built just like normal ones. External crutches are not used, everything is written in native code and embedded in the JDK (starting from 8)
  4. SceneBuilder is a visual editor for the layout of the interface. There you can clearly see what the application interface will be like. And it will not be necessary to restart the application a hundred times, checking if you correctly opened the table.