IntelliJ IDEA 14.0.0 Web Help

Preparing for JavaFX application development

To prepare for JavaFX application development:

  1. Download and install JDK 7 or a later version (earlier JDK versions don't include the JavaFX SDK necessary for JavaFX application development).
  2. If you are going to use JavaFX Scene Builder, download and install it as well.
  3. Make sure that the JavaFX plugin is enabled. (JavaFX support in IntelliJ IDEA in based on the JavaFX plugin. This plugin is bundled with the IDE and enabled by default.) See Making sure that the JavaFX plugin is enabled.
  4. Define the JDK in IntelliJ IDEA. You can do that separately (see Defining JDK 7 in IntelliJ IDEA) or when creating a project or module (see Creating a project for JavaFX application development from scratch).
  5. If necessary, specify the path to the JavaFX Scene Builder executable file. If you do so, you'll be able to open your FXML files in the Scene Builder right from within IntelliJ IDEA. See Specifying the path to the JavaFX Scene Builder executable file.
  6. Create a project for your JavaFX application development. Your can create the corresponding project from scratch or, if you already have the source files you want to continue working with, you can create a project by importing the corresponding sources. See Creating a project for JavaFX application development from scratch or Creating a Project by Importing Existing Sources. See also, Using Scene Builder with IntelliJ IDEA.

Making sure that the JavaFX plugin is enabled

  1. Open the Settings dialog (e.g. Ctrl+Alt+S).
  2. In the left-hand part of the dialog, under IDE Settings, select Plugins.
  3. In the right-hand part of the dialog, on the Plugins page, type fx in the search box. As a result, only the plugins whose names and descriptions contain fx are shown in the list of plugins.
  4. If the check box to the left of JavaFX is not selected, select it.
  5. Click OK in the Settings dialog.
  6. If suggested, restart IntelliJ IDEA.

Defining JDK 7 in IntelliJ IDEA

  1. Open the Project Structure dialog (e.g. Ctrl+Shift+Alt+S).
  2. In the leftmost pane, under Platform Settings, click SDKs.
  3. Above the pane to the right, click add and select JDK.
  4. In the dialog that opens, select the JDK installation directory and click OK.
  5. Click OK in the Project Structure dialog.

Specifying the path to the JavaFX Scene Builder executable file

  1. Open the Settings dialog (e.g. Ctrl+Alt+S).
  2. In the left-hand part of the dialog, under IDE Settings, select JavaFX.
  3. In the right-hand part of the dialog, on the JavaFX page, click browseButton to the right of the Path to SceneBuilder field.
  4. In the dialog that opens, select the Scene Builder executable file and click OK.
  5. Click OK in the Settings dialog.

Creating a project for JavaFX application development from scratch

  1. If no project is currently open in IntelliJ IDEA, click Create New Project on the Welcome screen. Otherwise, select New Project from the File menu.

    As a result, the New Project wizard opens.

  2. On the first page of the wizard, in the left-hand pane, select JavaFX.

    In the right-hand part of the page, specify the SDK (JDK) to be used in your project.

    Select the JDK from the list, or click New, select JDK and select the installation folder of the desired JDK.

    Note that the JDK version 7 or later should be specified.

    Click Next.

  3. Specify the project name and location, and click Finish.

Exploring the project

Let's take a quick look at what we've got in the project.

NewProjectJavaFXInitialStructure

The folder src is for your source code. In this folder, there is already a package called sample containing three files:

  • Main.java. This is the main application class for starting the sample application.
  • sample.fxml. This is the FXML file for defining the user interface.
  • Controller.java. This is the controller class intended to handle user interactions with the UI.

In addition to the sample application source code, there is a run/debug configuration for running or debugging the application. The run configuration has the same name as the main application class (Main) and is shown in the run configuration selector on the toolbar.

JavaFXRunConfig

There is also an artifact configuration intended for packaging your application. (This artifact configuration is not visible at the moment). We'll discuss this configuration later (see Packaging JavaFX Applications).

Running the sample application

To make sure that everything is fine with the project, let's run the sample application straight away:

  • Click run on the toolbar.

IntelliJ IDEA compiles the source code and then starts the application. The application window appears which, at the moment, is empty.

JavaFX01AppWindow01

Close the application window.

See Also

Language and Framework-Specific Guidelines:

Web Resources:

Last modified: 4 December 2014
comments powered by Disqus