Getting Started With JavaFX Technology Using Eclipse IDE

Working With JavaFX Samples

This section explains how to work with JavaFX sample applications that are packaged with the JavaFX plugin for Eclipse. It also provides a link to other available JavaFX samples outside of the IDE. You use the Display Shelf sample application in the steps below.

Note: Not all of the bundled sample applications are implemented using the common profile of the JavaFX application programming interface (API). The common profile allows a JavaFX application to be run on both desktop computers and mobile devices. The sample JavaFX applications that can be run using the mobile emulator (available on Windows platform only) and packaged with the JavaFX plugin for Eclipse are indicated with the icon.

  1. Ensure that your Eclipse IDE already has the JavaFX SDK and the JavaFX plugin for Eclipse software installed. If necessary, revisit the What to Download and Install section.

  2. Start the Eclipse IDE, if it is not already started.

  3. From the main menu of the IDE, create a new JavaFX project by using File > New > Project.

  4. In the New Project wizard, expand the JavaFX node and select JavaFX > JavaFX Project from Template. Click Next.

  5. In the Templates Projects page, select the Display Shelf sample project from the Available Templates list, as shown in Figure 1 and click Finish.

    A description and link to a web page with more detailed information about the sample application project are included for the template projects that are listed outside of the Building Blocks folder.

    List of Available Templates of JavaFX Sample Projects. Figure 1: List of Available Templates of JavaFX Sample Projects

    The project is added to the Package Explorer.

  6. In the Package Explorer, expand the Display Shelf > src > displayshelf.

  7. Right-click the node for Main.fx and select Run As > JavaFX Application.

  8. Click Run in the Edit Configuration and Launch dialog box.

    The project is executed by using the Desktop profile.

  9. You can set a different Run configuration profile by right-clicking Main.fx node again in the Package Explorer and selecting Run As > Run Configurations. Select from the Profile-Target drop-down list, as shown in Figure 2. However, remember that only mobile-ready projects can be run with the Mobile profile configuration.

    Run Profiles Configurations Available.Figure 2: Choosing One of the Run Profile Configurations Available

  10. Examine and modify the application by looking at the source files under JavaFXSample > src > displayshelf node, right-clicking one of the source files (for example, Main.fx ), and selecting Open.

    The source file is displayed in the source editor.

  11. See other JavaFX samples available in the JavaFX Sample Gallery.