What are JavaFX, FXML and Scene Builder?

18,111

Solution 1

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.

Solution 2

If you've heard of/used Swing before, think of JavaFX as its cooler, easier-to-use alternative and replacement (JavaFX is to replace Swing as java's main platform for desktop and internet applications, although both will continue to be supported in the foreseeable future).

FXML is nothing more than:

a XML-based user interface markup language created by Oracle Corporation for defining the user interface of a JavaFX application

You can create your user interface directly by code, or in the fxml file with a .fxml postfix. E.g., my_ui.fxml

One of the most important tools in JavaFX applications development is the JavaFX Scene Builder (Snapshot below) It allows you to easily drag and drop controls (widgets) to create your UI in minutes:

enter image description here

The code for this layout is generated automatically (in your_layout.fxml file) as you drag items into your layout.

Take a look at these cool tutorials on JavaFX:

Getting Started with JavaFX

Share:
18,111
TomJ
Author by

TomJ

Am friendly...

Updated on June 06, 2022

Comments

  • TomJ
    TomJ almost 2 years

    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.

  • TomJ
    TomJ about 10 years
    Thanks for the answer. I got a better understanding now. The "Learn JavaFX" link you posted has already visited by me. It explains the steps using Eclipse. I need such a tutorial of NetBeans. Can you provide me one ?
  • Aman Agnihotri
    Aman Agnihotri about 10 years
    The second link which I have posted has videos from JavaOne 2013 and programmers there have used NetBeans to teach JavaFX features.
  • Asif Mushtaq
    Asif Mushtaq almost 8 years
    @AmanAgnihotri where I can find all FXML tags/attributes? mean all tags like id: fx:id controller etc....