Essential JavaFX PDF Print E-mail

by Gail Anderson and Paul Anderson

Published by Prentice Hall

Review by Claron Twitchell

If you keep the title in mind, Essential JavaFX, this book does exactly what it proposes to do.  It explains the essentials of JavaFX.  The Andersons have a clear writing style.  They start out at the beginning with simple code examples and each chapter builds on previous material with more examples that leverage off of the previous examples.  By the last two chapters, 9 and 10, they show how to use animation and pictures downloaded from Flickr using web services in an interesting photo carousel application and run it on the desktop or a mobile device.  They use the 360 pages of this book to good advantage for your first crack at JavaFX.

 

The authors do an above average job at introducing chapters.  You get in your mind what you should be learning in the chapter just before you dive into the chapter.  (See the example for chapter 2 in the sample content.)


You can see a sample chapter, table of contents and index with the sample content on the publisher's website.  The authors have the source code for the examples down-loadable at http://www.asgteach.com/javafx.

 

For a member who purchases the book from the publisher site, he/she will have instant complimentary access for 45 days to the Safari Books Online version of the book.  You can see that process here on the product page, http://www.informit.com/title/0137042795 in the right-hand side box with the check box.


I love language design, so "Chapter 3 JavaFX Language" was one of my favorite chapters.  The authors did a nice job of covering pretty much everything you want to know about the essential aspects of the language in 52 pages.  The syntax looks a lot like Java as you would expect.  The rules are a little more relaxed, as you would expect for a scripting language, than they are in big mother languages like C++ or Java.  For instance, you can declare a variable with "var count = 0;" and since JavaFX has a sophisticated inference engine, you don't have to declare the type, it just figures it out.  However, you can specify the type with "var count: Integer = 0;" if you prefer.  There are some fun features with sequences.  "var k = [1..3 step .5];" gives you [1.0, 1.5, 2.0, 2.5, 3.0].  Values are returned from many code constructs like if constructs, code blocks and for loops.  So, you can get fun results returned from constructs, for example "def seq = for (n in [2..6]) [n, 2*n];" yields a sequence of [2, 4, 3, 6, 4, 8, 5, 10, 6, 12].

JavaFX runs on the JVM and it has easy access to Java.  So, anything you need in the Java libraries is close at hand.  Insert an "import java.lang.Math;" makes "Math.PI * radius * radius;" work.  You can create Java objects easily:


var today = new java.util.Date;
var timeNow = java.text.DateFormat.getTimeInstance().format(today);
println(timeNow);  // 4:41:30 PM

 

Chapter 4 gives you the beginnings of actually doing something with JavaFX.  They show how Stage includes a Scene object and Nodes to render graphical material.  They explain how to build graphical objects like Lines, Rectangles, Circles, Arcs, Quadcurves and so forth.  In this chapter, you start to notice that the authors use a good range of formats to make the book interesting and the material more comprehensible.  They use a nice mix of tables, figures, code listings, screen shots, programming tip inserts, and illustrations along with the text of the book.  In chapter six, they start to use scene node diagrams to give a top level view of an application.  The diagrams map very closely to how JavaFX uses scenes as the way to structure the code.

"Chapter 6 Anatomy of a JavaFX Application," has "Project Piano" which gives you a good idea of what a real JavaFX program looks like.  It uses inheritance, creates graphical objects, animation, timelines and GUI components and uses sequences and event handlers to manipulate them.  The application lets you play a two octave piano or play a prebuilt tune of "Twinkle Twinkle Little Star."  Every note is held for the same amount of time, so I am looking forward to going back into the code and adding adjustable note duration.

Chapters 7 and 8 cover animation and images, like jpg files.  Chapter 9 and 10 cover web services and mobile applications with code examples sufficient to see how it all works. 

The book did a good job covering the intended subjects and whetted my appetite to see how I can use it to build a web site, but that is the topic of the next 360 pages.

 
< Prev   Next >
Colocation provided by VersaServers