Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Jump into JavaFX, Part 1: JavaFX Preview SDK

Experience JavaFX with NetBeans 6.1 and Project Nile

  • Print
  • Feedback

Page 4 of 6

Rather than trying to figure out how the script works, let's see what it's like to build and run it in NetBeans 6.1 with JavaFX. After replacing Main.fx's skeletal contents (see Figure 9) with Listing 1, compile the source code and run the resulting Java class file by clicking the toolbar's Run Main Project button (the green triangle button). If all goes well, you should see a window that presents identical content to that shown in Figure 10.

The script continuously rotates the message around the center of the window's content area, while also transitioning the message's opacity from invisible to fully visible and vice-versa.

Figure 10. The script continuously rotates the message around the center of the window's content area, while also transitioning the message's opacity from invisible to fully visible and vice-versa.

More sample applications

NetBeans 6.1 includes a variety of samples that primarily demonstrate JavaFX's support for animation, basic geometry, color, images, and mouse interaction. You can even have fun with the somewhat buggy Bounce sample, which presents a simple version of the popular Arkanoid game. If you haven't yet tried out these samples, Figure 11 gives you a glimpse of what's available.

Bounce, Color Wheel, Linear Gradient, Smoke Particle System, and Transparency sample GUIs.

Figure 11. Bounce, Color Wheel, Linear Gradient, Smoke Particle System, and Transparency sample GUIs. (Click to enlarge.)

Before you can play with a sample, you'll have to create a new project. Complete the following steps to accomplish this task:

  1. Activate the New Project wizard.
  2. From the Choose Project section of the wizard's starting screen, expand the Samples category node, followed by the JavaFX and Best Practices nodes in the Categories tree.
  3. Select a directory under Best Practices and highlight the desired project in the Projects list.
  4. Click Next and then Finish.

After you click Finish, the sample becomes the new main project. Click the green triangle button to compile and run its code.

To view the sample project's source code, expand its Source Packages hierarchy on the Projects tab of the workspace's Projects/Files/Services window, and double-click the appropriate .fx filename that's located at the bottom of this hierarchy. A new tab will be created that presents this file's source code.

More about the NetBeans IDE with JavaFX

To find out more about the NetBeans IDE, check out the NetBeans IDE Java Quick Start Tutorial page at NetBeans.org. Additionally, you might want to keep in mind that the File menu contains a Set Main Project menu item that lets you easily choose which of the various open projects is the main project -- clicking the green triangle button (or pressing F6) compiles and runs the main project. Also, you can close the main project by selecting File's Close "project name" menu item, and open any project not already open by selecting File's Open Project menu item. If you want to learn more about working with JavaFX in the NetBeans IDE (such as how to debug a malfunctioning script), first select Help Contents from the Help menu to access the IDE's help system, and then select one of the topics under JavaFX Applications (such as Debugging JavaFX Applications) on the help window's Contents tab.

Using Project Nile

Project Nile provides an Adobe Illustrator Creative Suite 3 (CS3) plugin that lets UI designers export Illustrator-based visual elements to FXD files (files based on the JavaFX Data, or FXD, format, and having the .fxd extension), or FX files (JavaFX Script source files, with the .fx extension). It also provides an Adobe Photoshop CS3 plugin for exporting Photoshop-based elements to the same kinds of files.

  • Print
  • Feedback

Resources

More from JavaWorld