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.
- 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.
- Start the Eclipse IDE, if it is not already started.
- From the main menu of the IDE, create a new JavaFX project by using File > New > Project.
- In the New Project wizard, expand the JavaFX node and select JavaFX > JavaFX Project from Template. Click Next.
- 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.
The project is added to the Package Explorer.
Figure 1: List of Available Templates of JavaFX Sample Projects
- In the Package Explorer, expand the Display Shelf > src > displayshelf.
- Right-click the node for
Main.fxand select Run As > JavaFX Application.
- Click Run in the Edit Configuration and Launch dialog box.
The project is executed by using the Desktop profile.
- 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.
Figure 2: Choosing One of the Run Profile Configurations Available - 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. - See other JavaFX samples available in the JavaFX Sample Gallery.
Cindy Castillo
Technical Writer, Oracle Corporation