Creating a JavaFX Project

In this recipe, we will install the plugins required for working with JavaFX and also create our first project that will serve as the basis for some of the next recipes.

Getting ready

There are two options to start working with NetBeans:

First, it is possible to download the specific IDE for JavaFX from the NetBeans site. Just go to the download section and select the JavaFX version.

Second, if NetBeans is already installed on your machine, simply open the IDE, click on Tools and Plugins, then select the following components:

  • JavaFX Bind Inspector (if Bind Inspector is not shown, click on the name header and sort by name first)
  • JavaFX Composer
  • JavaFX Kit

And click Install.

Getting ready

Follow the steps of the NetBeans IDE Installer and accept a License Agreement. The NetBeans plugins will be downloaded and installed automatically. At the end of this process, the IDE will ask if you wish to restart the IDE, choose Restart IDE Now and click Finish.

When the IDE completes the installation of the plugins, it restarts and after that we are ready to go.

How to do it...

To Create a New Project:

  1. Click on File and then New Project (or press Ctrl+Shift+N).
  2. Choose Project: In the New Project window, on the Categories side choose JavaFX and on Projects side select JavaFX Desktop Business Application, and click Next>.
  3. Under Project Name, enter JavaFXApp, leave all the other fields with their default values and click Finish.
How to do it...

How it works...

NetBeans, in conjunction with JavaFX SDK, creates a project structure, assigns the necessary libraries for the project to work, and creates Main.fx.

Main.fx is the main class that we will be building our future applications on, and where we will place the components from the JavaFX Palette.

Note that due to NetBeans JavaFX Composer, the Main.fx is already created and presented with the visual Components Palette and the design mode on.

Below is the file structure of our newly created project:

How it works...

There's more...

Feeling curious about JavaFX?

Available samples

The JavaFX SDK provides samples of what can be done with JavaFX.

To check them out:

  1. Create a New Project, this can be achieved by clicking on File and then New Project (or pressing Ctrl+Shift+N).
  2. Choose Project: In the New Project window, on the Categories side, expand the Samples node and choose JavaFX and on Projects side there are many project samples.

The list of available examples is extensive and will cover pretty much all the needed functionality and APIs that a developer might need.

Examples of these projects are:

  • Drag and Drop example
  • Google Image Search
  • JDBC Address Book
  • RSS Reader

And many more.

Just open one and start learning more about JavaFX.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.218.105