Vous êtes ici

My first JavaFX application - 1 - First contact

javaI need to write some Java code to configure and drive a hardware device connected to a PC.

Associated UI does not have to be complex:

  • let the user select a serial port and set its characteristics (speed, byte format)
  • let the user create some specific frames and send them to the device
  • display frames received from the device

but it's not trivial either.

For several previous projects, I used SWT, because I wanted a native look and feel for my applications. SWT is really nice, but it's not part of Java, and I was not able to find a lot of documentation. I heard about JavaFX some time ago. One good point for it: it's part of the JRE. And it seems to be quite well documented. So I think it's time for me to give a look to it.

Environment

I'll write my application in the following environment:

In addition to what is said just above, Scene Builder has to be installed. It can be downloaded from here. Then, in eclipse, set the path to Scene Builder executable (Window / Preferences / JavaFX).

Refer to this article, for an updated installation procedure.

Let's start

Several non-trivial sample applications can be downloaded, as explained here. The Ensemble demo provides an overview of JavaFX capabilities.

Tutorials for e(fx)clipse are available here. Tutorial 1 shows how to create a trivial application and how to generate a standalone jar file. Then, integrating the Hello World sample from Oracle website is easy. The Form tutorial gives a useful hint: how to display the grid lanes of a grid pane.

Some additional resources worth mentioning:

Next article