Book Code


Getting started with JavaFX 2 Introduction by Example Book

JavaFX 2.x Introduction By Example Application Sampler

If you’ve purchased the book “JavaFX 2.0 Introduction by Example” and recently obtained the code from the book’s site you will noticed that some of the examples don’t work quite like they used to. That’s because of the time of the writing of the book I was using preview editions leading up to JavaFX 2.0 GA (API changes & bug fixes). To get the latest code you’ve come to the right place. If you haven’t purchased the book I encourage you to head on over to your favorite bookstore to get yourself a copy (Amazon, Barnes&NobleApress).

On this page I will provide instructions for the most popular IDEs (NetBeans, Eclipse, and IntelliJ) and the latest and greatest of the book’s source code examples. This page is a work in progress. Having said that I currently (only) have instructions for the NetBeans 7.2 IDE shown below. As time goes by I will continue to update this site with instructions for the other IDEs listed. The book also details on how to use the command line to compile and run the examples.

Software Requirements

Instructions

  1. Download Java 7 update 6 which includes JavaFX 2.2 from Oracle: http://www.oracle.com/technetwork/java/javase/downloads/index.html

    Oracle’s Java download site

  2. Read license agreement and click on the accept (radio button) button
  3. Download the JDK that’s based on your operating system (OS)
  4. After the download you will launch the installer

    Java 7 Installer

    Java 7 Installer

  5. Click Next which then proceeds with a progress bar preparing the installation process.

    Installer prepping

  6. You are presented the location to install. Shown below is the Java home or default on the Windows platform. Just click Next.

    Java home directory

  7. Successful Installation window. Click the close to finish.

    Successful JDK Install

  8. Download NetBeans 7.2 from:  http://netbeans.org/downloads/index.html
  9. After download launch the installer

    NetBeans Installer

  10. Click Next
  11. Accept the terms of the license agreement after you have read it. Click on check box then click on the Next button.

    Terms of the license agreement

  12. Do the same for the JUnit license agreement and click Next
  13. Choose the installation folder and JDK by clicking on the browse button to locate a destination directory. Shown below are the defaults for Windows operating system (C:\Program Files\NetBeans 7.2). You’ll notice that it picks up the latest JDK 7 that was installed. Click on the Next button.

    Choosing a destination folder to install NetBeans

    Choosing a destination folder to install NetBeans

  14. Proceed by clicking the Install button shown below:

    Begin the Install

    Begin the Install

  15. The installation process is underway. Shown below is the progress dialog:

    Progress dialog window installing NetBeans

    Progress dialog window installing NetBeans

  16. Once it is completed you will get a dialog message showing that you succeeded. You should now be ready to launch the NetBeans IDE. Shown below is the newly installed application in the start menu of the Windows platform:

    Newly installed NetBeans application

    Newly installed NetBeans application

  17. Select the NetBeans IDE 7.2 Icon to launch.

    Launching NetBeans IDE

    Launching NetBeans IDE

  18. Once started you should see the main menu options and the start page tab is displayed.

    Start Page NetBeans IDE

    Start Page NetBeans IDE

  19. Download the book’s NetBeans source code project (zip file). You can download the zip file from the GitHub https://github.com/carldea/JavaFX2IntroByExampleCode/blob/master/netbeans/NetBeans-JavaFX2IntroByExampleAppSampler-20120904.zip?raw=true
    Most browsers you will simply right click and ‘Save as link As‘ to a file to be downloaded.
  20. Import the zip file into the NetBeans IDE. On the menu select ‘File -> Import Project -> From Zip’. Depicted below is the import zip options:

    Import a NetBeans project zip file

    Import a NetBeans project zip file

  21. Locate the book’s zip file recently downloaded. Click the top Browse button to locate file.

    Import Project(s) from ZIP dialog window

    Import Project(s) from ZIP dialog window

  22. Select the zip file to be imported and click on the open button. Shown below is the File chooser to import zip file:

    File Chooser to select zip file

    File Chooser to select zip file

  23. You’ll return to the dialog showing the import dialog window with the zip file path and the project destination directory.

    Import Project(s) Zip dialog populated with source and destination

    Import Project(s) Zip dialog populated with source and destination

  24. After clicking on Import you should see the project on the left side of the IDE (project tab). Now click on the Green triangle on the tool bar to run the App Sampler Application to run all the examples.

    Project tab containing the project of JavaFX 2 Intro by Example book code.

    Project tab containing the project of JavaFX 2 Intro by Example book code.

  25. After launching the application you should see the application depicted below:

    App Sampler

    App Sampler

  26. To launch the examples double click a recipe in the table view of one of the chapter tabs.
Running one of the examples

Running one of the examples

*NOTES: derby.jar and derbytools.jar need to be included in the IDE’s classpath to run one of the examples (RSS feed reader). The example will still work if the jars aren’t referenced, you just won’t have RSS links saved when you relaunch the example.

Now that you have successfully installed and able to run the code you will be a JavaFX Ninja in no time! If you have any question don’t hesitate to leave me a comment.

Advertisement

2 thoughts on “Book Code

  1. Pingback: Java desktop links of the week, September 10 | Jonathan Giles

  2. Pingback: JavaFX links of the week, September 10 // JavaFX News, Demos and Insight // FX Experience

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s