JavaFX helps to create the interface of a Java application
But what JavaFX offers more than XAML or HTML 5 or Swing? Who will be most interested in this new solution from the Java editor?
The image below show an example of application made with JavaFx and it look amazing.
The MP3 player is a demonstration of interface made with JavaFX.
It is provided on the JavaFX site with its source code.
Actually, it is intended for programmers as well as designers.
Java wants to go beyond the desktop and move on browsers as well as on mobile devices and any multimedia device.
This makes as a goal a RIA platform for use directly or indirectly by:
- Web developers.
- Authors of content.
- Graphic designers.
So webmasters are involved by this framework in all functions related to the user interface.
A framework for both the desktop, web and mobiles
JavaFX wants to be the framework for Web applications and mobile applications. That puts it in competition with several already popular framework as well as Android, the development platform and mobile OS from Google.
It makes it easier to achieve interfaces that Swing, however, the components of the latter have not all equivalent on JavaFX. Over time it ceases to be the case.
The JavaFX site focuses on audio and video capabilities, rich text and graphics vector, animations and web services. It offers examples that will work on your computer with the last version of Java.
In 2018, Oracle decided to make JavaFX a tool separate of Java, and to distribute it on the OpenJFX site. At the same time it increases its investment in AWT/Swing, which indicates a lack of interest in JavaFX.
The current Java runtimes for PC and mobile reveal inconsistencies. JavaFX wants to remove them and offer a unique framework for all online applications. The applications for mobile devices can therefore run on PCs. The same applies to web applications, it will be possible to move an application running in a web page on the desktop by simply drag and drop.
The platform consists of several parts:
- The development environment.
It includes a compiler, a runtime, and the NetBeans IDE with a dedicated plug-in.
Plus a mobile emulator to develop applications, similar to what is offered by Android which uses also the Java language.
Scene Builder is a tool to visually describe the entire application interface before adding components. Then connect the interface to the Java code. - The production suite.
A set of tools and plug-ins for interfacing JavaFX with software such as Photoshop, and therefore use them more easily to make the design of web applications. - JavaFX Desktop.
As with Mozilla Chromeless and the offline mode of HTML 5, Web applications can be installed on the desktop. In this case, these are the applets embedded in pages that operate locally. - FXML, the description language interface is the counterpart of XAML or XUL.
- The runtime includes Prism, a graphics engine for hardware acceleration, a Web component. A plugin add it to the browser.
- The installer which creates a package installable as a standalone application, including the runtime. It uses at programmer choice to Inno Setup, to the creator of MSI files from Microsoft, or to equivalent tools for each operating system.
To start developing an app, download the SDK and read the getting started manual.
To facilitate the development, a new programming language, JavaFX Script, was presented as allowing to replace in 25 lines what is written in 100 lines of Java but it is no longer supported since the version 2.0 of JavaFX and must be forgotten.
Installing native-like
Since version 2.2, it is possible to install an application built with JavaFX as a binary application without it depends on the prior installation of Java runtime on the machine.
The application is packaged with its own runtime, a personal copy of the Java classes necessary for its operation as well as images and other resources for the interface. At the expense of disk space, but eliminating any compatibility issues.
Thus we no longer need a compiler such as GCJ to produce an executable. This system was perfect at the time when computers were slower and the runtime included fewer classes. Their gradual increase discouraged developers of Java to binary compilers.
Today's computers can provide enough power to make a JIT interpreter fast enough, and this packaging simplifies especially the installation.
A reason for the appearance - a little late - of this system is after it lost the lawsuit against Google, Oracle sees this as a way to install the standard Java (not Dalvik) on Android phones.
Conclusion
Examples given on the site are impressive. This new framework starts with strong arguments: the universality of applications, the free NetBeans development tool that significantly simplifies the design of software. JavaFX further complicates the choice of developers who now hesitate between three platforms at least: HTML 5, XAML and JavaFX!
See the list of GUI for an extensive choice of platforms to make an application.