Set Up a JavaFX Project in NetBeans with Scene Builder

JavaFX remains a practical choice for desktop applications that need a polished graphical interface, charts, forms, media controls or responsive layouts. NetBeans provides project management, code completion and debugging, while Scene Builder lets you arrange controls visually and save the design as FXML.

This workflow suits students, hobby developers and professional teams across Australia, whether you are working from a home office in Brisbane, studying in Melbourne or maintaining an internal tool for a Sydney business. Before starting, review the NetBeans background if you are unfamiliar with the IDE’s project model and Java support.

Choose a Compatible Java Stack

Install a current JDK rather than a JRE. JavaFX is distributed separately from the JDK, so you need an OpenJFX distribution or Maven dependencies as well. Long-term support versions such as Java 17 or Java 21 are sensible choices for coursework and production applications.

Download Apache NetBeans from its official distribution channel and verify that the IDE detects the selected JDK under its Java platform settings. On macOS, Windows and Linux, the menu names are similar, although the Java installation path differs. Australian developers using a managed work laptop may need administrator approval before installing Scene Builder or changing environment variables.

Create the Maven Project

In NetBeans, select File > New Project, choose Java with Maven, and create a basic Java application. Give it a clear group ID, such as au.example, and an artifact ID such as customer-dashboard. Maven is preferable to manually copying JAR files because it downloads compatible modules and keeps the build repeatable.

Open pom.xml and set the Java release to the version installed on your machine. A typical configuration uses the JavaFX controls and FXML modules, plus the JavaFX Maven plugin:

<properties>
    <maven.compiler.release>21</maven.compiler.release>
    <javafx.version>21.0.2</javafx.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>${javafx.version}</version>
    </dependency>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-fxml</artifactId>
        <version>${javafx.version}</version>
    </dependency>
</dependencies>

Use a JavaFX version compatible with your chosen JDK. Maven Central may offer a newer patch release, so check the current version before finalising a team project.

Configure JavaFX Dependencies

Create a main class that extends javafx.application.Application. Its start method receives the primary stage, loads an FXML file and displays the scene. Keep FXML files in src/main/resources, commonly inside a package directory such as au/example/view.

public class App extends Application {
    @Override
    public void start(Stage stage) throws IOException {
        FXMLLoader loader = new FXMLLoader(
            App.class.getResource("main-view.fxml"));
        Scene scene = new Scene(loader.load());
        stage.setTitle("Customer Dashboard");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}

If the application uses module-info.java, export the package containing the application class and open the controller package to javafx.fxml. Without the opens directive, Scene Builder may display the file correctly while the running application fails to access controller fields or methods.

Install And Connect Scene Builder

Gluon Scene Builder is a visual editor for JavaFX layouts. Install the version suited to your operating system, then configure its executable in NetBeans under the JavaFX or Tools > Options settings, depending on the NetBeans release. Right-click an FXML file and choose the Scene Builder command when the integration is available.

Open main-view.fxml and drag controls from the Library panel onto a layout container. Use a BorderPane, VBox, HBox or GridPane to create a resizable structure rather than positioning every component with fixed coordinates. Set meaningful fx:id values for controls that the controller must access.

A form for an Australian small business might include customer name, suburb, invoice amount and a date field. If it stores personal information, design the application with the Privacy Act 1988 and the Australian Privacy Principles in mind: collect only necessary data, protect saved files and avoid placing real customer records in sample projects.

Design The FXML Interface

In Scene Builder, select the root container and assign a controller class, such as au.example.controller.MainController. Add buttons, labels and input fields, then set event handlers such as #saveCustomer in the Code panel. Save the document and return to NetBeans to inspect the generated XML.

The controller should contain presentation logic rather than database code. Use @FXML for injected controls and validate input before updating the model. For example, an amount field should reject malformed currency values instead of allowing an exception to reach the user. A developer building a seafood catalogue could keep recipe or product content in a separate service; reference material such as sea bass recipes can remain outside the UI code.

Run And Debug The Application

Run the project with NetBeans’ Maven goal or the configured JavaFX plugin. If the application reports that a JavaFX class cannot be found, inspect the dependency tree and confirm that Maven has downloaded the controls and FXML modules. A module-path error usually indicates that the runtime configuration does not match the JDK or JavaFX version.

When an FXML load fails, read the first Caused by message carefully. Common causes include an incorrect resource path, a controller package that is not opened, a misspelled fx:id or an event method with the wrong signature. NetBeans breakpoints work in controller classes, making it straightforward to follow button actions and validation failures.

For larger Java applications, documentation makes handover easier. You can generate API references with JavaDoc generation, particularly when a JavaFX client calls service classes or shares domain models with a backend. Developers working with enterprise services can also compare the application structure with this JTA transaction guide.

Compare Practical Project Options

The best setup depends on whether the application is a learning exercise, an internal business tool or a distributable desktop product. Maven reduces manual configuration, while Scene Builder is most useful when layouts contain several nested controls and need regular visual adjustments.

Setup Strengths Limitations Suitable use
Maven with JavaFX modules Repeatable builds and dependency management Requires familiarity with pom.xml Most new projects
Manual JavaFX SDK configuration Clear understanding of runtime files More difficult to share and maintain Short experiments
Scene Builder with FXML Visual layout editing and cleaner controllers Adds a separate design tool Forms and dashboards
Java-only user interface Everything remains in source code Tedious for complex layouts Small prototypes
Modular JavaFX application Strong encapsulation and clearer packaging Requires careful exports and opens settings Larger applications

After the first successful run, commit pom.xml, source files and FXML to version control, but exclude IDE-specific build output and private user data. This gives a team in Adelaide, Canberra or elsewhere in Australia a consistent starting point when the project moves between machines or Java versions.