What are the benefits of using JavaFx over Swing ?
Joined: Jun 20, 2008
I am new to javaFx. I have build my first hello world JavaFx Application. still trying to understand what are the benefits of using JavaFX? Can we add JavaFX GUI to existing Swing GUI? Can we Use JavaFx GUI from Java code?
Are there any good web sites, books, that will help some one to get started and understand it well? may be something like Head First series....
Joined: Jul 07, 2009
You can write JavaFX Swing programs using much less code because JavaFX performs all of the Swing-based housekeeping for you. You don't have to register event listeners and it writing action functions is more concise. Furthermore, with the JavaFX binding mechanism, it is simple to integrate the GUI components with your underlying model. Binding in JavaFX is very powerful.
The JavaFX declarative style not only makes your code more readable, but it makes it more concise too.
While you can use the JavaFX swing components, you can also use JavaFX "native" components that include TextBox, Button, Hyperlink, ToggleButton, RadioButton, ToggleGroup, CheckBox, ListView, Label, ScrollBar, Slider, ProgressBar, ProgressIndicator. The advantage of the "native" controls is that they work in all environments: desktop, mobile, and tv, while swing-based controls work only in the desktop environment.
Our book, Essential JavaFX, is meant to get you up to speed with JavaFX quickly. It has a chapter on UI controls, both the "native" ones and the swing-based controls. Here is an example of an using the swing-based controls that lets you order a pizza. It takes advantage of the ability to easily use graphical objects with JavaFX.