What are JavaFX, FXML and Scene Builder?

TomJ picture TomJ · Mar 16, 2014 · Viewed 16k times · Source

I am new to JavaFX, and am trying to do a project in it. In some tutorials they mention FXML. What is the difference between the two?

I am using NetBeans IDE to develop my project, and heard about using Scene Builder when working with FXML. What exactly is Scene Builder? Should I use JavaFX, FXML and Scene Builder to develop my project smoothly?

Please answer the above questions in simple language. If possible, provide me some good tutorials on how to use JavaFX.

Answer

Aman Agnihotri picture Aman Agnihotri · Mar 16, 2014

Think of JavaFX as a bunch of packages which allows one to create rich internet and desktop applications.
If you know Swing or AWT, then you know that they are used to create GUI applications. JavaFX also allows you to create GUI applications, but with less programming, and with more visual effects at your disposal.

FXML is a file format which JavaFX uses to create the layout of screens, though you can even code your user interface directly. Although its much more easy to create FXML files using SceneBuilder.

SceneBuilder is an application where you can drag and drop JavaFX UI components, and then tell your JavaFX program to use the fxml file(s) to display the user interface.

Here's a nice tutorial: Learn JavaFX And you can check out the JavaOne 2013 JavaFX based videos from the following link: JavaFX at JavaOne 2013.

Official Oracle Tutorials on JavaFX are highly recommended. These tutorials cover FXML, SceneBuilder, CSS and many other topics. As you are using NetBeans, using the Oracle tutorials should be straightforward as they all ship with NetBeans projects (just look for the project zip files in the columns on the right of each tutorial page).

I would suggest that you download JDK 8 and use JavaFX 8, and use the new capabilities of Java 8 in your JavaFX application like Lambda Expressions, etc to make your code compact and clean.