Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼

Eric Bruno

Dr. Dobb's Bloggers

The JavaFX SceneBuilder Tool

May 14, 2012

Oracle recently released a preview of a new tool to help with GUI layout for JavaFX 2.x applications, called the JavaFX SceneBuilder. It's available for Windows, Mac OS X, and Linux, and you can download it here. It's available on all of these platforms because it's built on Java itself.

More Insights

White Papers

More >>


More >>


More >>

It sports a very clean, easy-to-use interface, which is consistent with the JavaFX mantra. Here's the screen as greeted when you start the application:


You can then add layouts, shapes, and controls to the canvas, position and resize them as you please, and save when you're done. To do so, simply drag-and-drop from the available components in the list along the left, into the correct area of your canvas in the middle. The result is an FXML file, which is an XML-based layout structure used by JavaFX, and combined with a CSS file, to form the skinned GUI of your application.

Bind Code to GUI

If you save this file along with the source code for your JavaFX project in NetBeans, you can bind elements of your GUI in SceneBuilder, along with associated events and actions, with your code. To do so, you need to have the elements defined in your code, usually within a controller class, select the relevant component in SceneBuilder, and set the Controller Class in the Document section along the right-hand navigation (see figure below).


You define the appropriate elements in your code as such:

package mycooljavafxapp;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;

public class AppController implements Initializable {
    Button helloBtn;

    public void initialize(URL url, ResourceBundle rb) {
    public void onHelloButton(ActionEvent event) {
        System.out.println("Hello, World!");

Then bind to your controls as shown below:


Next, you can bind a control's event by selecting the control, then the proper event method from the drop-down list within the Events section of the tool, as shown below:


You can find more information on JavaFX and the JavaFX SceneBuilder here, along with a Getting Started Guide.

Happy coding!


Related Reading

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.