Adverts
As is traditional the first application you write when learning a new language or technology should be the HelloWorld application and JavaFX is no different. Unlike other Java applications the JavaFX HelloWorld application is really quite small and easy to understand. The first thing you need to do is setup your development environment for JavaFX as described. Create an FX file called HelloWorld.fx and then enter the following code:
import javafx.ui.*;
Frame {
title: "JavaFX Hello World"
content: Label {
text: "Hello World"
}
visible: true
}
This is about as simple as you could get and pops up a window (a JFrame) with the title "JavaFX Hello World" which contains a panel with a label that says "Hello World". The window is set finally set to be visible. While a good introduction to JavaFX and the simplicity of the language this isn't a terribly interesting example and it is time to move on.