April 17, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Using NetBeans to Develop a JavaFX Desktop Application

  • July 1, 2009
  • By Anghel Leonard
  • Send Email »
  • More Articles »

In the spring of 2007, Sun released a new framework named JavaFX. The main component of JavaFX is JavaFX Script, which is a declarative scripting language that mixes the best capabilities of the Java platform with classes designed for implementing media functionalities in an easier manner. Now, you can develop GUIs, animations, audio/video players, and cool effects for text and graphics, as well as access web services for the desktop, browser, and mobile platforms with only a few straightforward lines of code. In addition, you can wrap Java and HTML code into JavaFX Script.

In December 2008, Sun unveiled the release of JavaFX 1.0, a new platform that merges form and functionality for building rich Internet applications (RIA) with immersive media and content for web browsers and desktops. Looking forward, the newer NetBeans release contains support for JavaFX 1.0 under the NetBeans IDE 6.5 for JavaFX 1.0 name.

This article explains how to use this NetBeans release to develop a JavaFX Script desktop application.

Download and Install NetBeans 6.5 for JavaFX 1.0

This section presents the prerequisites for following the remainder of the article. You should be in one of the following scenarios:
  • You have a previous NetBeans version and you want the JavaFX plug-in. Use this guide to get the plug-in.
  • You want to download NetBeans 6.5 and JavaFX 1.0 as a bundle. Download it from the NetBeans site and just follow the setup instructions.

For system requirements, check the JavaFX spec page.

A Brief Presentation of the Application

In the following sections, you'll develop five JavaFX classes (*.fx) that will develop a desktop application named DeltaCars. Basically, the application will mimic a commercial for a company that rents cars. The potential clients can see a video presentation of the company, available cars, prices, contacts, and so on. In principle, four of the five classes will represent individual graphical components and the last class will represent the main class of the application (see Figure 1). This main class will be the application stage. Every class will wrap the graphical capabilities of the represented component, such as transparency, events listeners, translations, interactions, effects, audio/video components, etc.



Click here for larger image

Figure 1: Splitting the Application into JavaFX Classes

Create a JavaFX Project Stub

Because NetBeans comes with a JavaFX engine and JavaFX support, creating a JavaFX project stub is a very simple task. Start by launching NetBeans 6.5 and then following with these steps:
  1. From the main File menu, select the New Project option (this will open the New Project wizard).
  2. In the Choose Project, Categories section, select JavaFX from the available categories. This will activate a list of JavaFX project types in the Projects section.
  3. You will see only one type of JavaFX project, JavaFX Script Application. Select it from the Projects section and press the Next button. You should see the wizard page for the project settings.
  4. In the project settings page, enter the project name and location in the Project Name and Project Location fields. For this example, your project name is DeltaCars and its location is the C:\JavaApplications\JavaFX folder.
  5. Because you don't have/need a previous project or set of classes, select the Empty Project radio button for the DeltaCars project. If you selected the From Sources radio button, you would be prompted to provide the source package folders.
  6. Allow NetBeans to select DeltaCars as the main project and to generate the corresponding main class.
  7. Press the Finish button.

After you press the Finish button, NetBeans will generate the DeltaCars project stub. You should see its tree structure in the Projects view, the Main.fx class in the NetBeans main editor, and the JavaFX Palette (see Figure 2).



Click here for larger image

Figure 2: The DeltaCars Stub in NetBeans 6.5

If the JavaFX Palette is not visible by default, then you can activate it by selecting the Palette option from the Window main menu.


Tags: JavaFX



Page 1 of 5



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel