Burk is a long-time programmer and software architect, currently focused on the Java platform with an eye toward mobile platforms. In 2010, he was voted a JavaOne Rock Star for his talk on User Experience Anti-Patterns, and is a co-author of the books "97 Things Every Software Architect Should Know" and "97 Things Every Programmer Should Know". Burk is also a Sun Certified Programmer, Developer, and Enterprise Architect for JEE 5. Burk has posted 25 posts at DZone. View Full User Profile

Essential JavaFX

09.25.2009
| 12553 views |
  • submit to reddit
Published by: Prentice Hall/Sun Microsystems
ISBN: 0137042795

Reviewer Ratings

Relevance:
4

Readability:
5

Overall:
4

Buy it now

One Minute Bottom Line

This is a good book for an experienced developer who wants to get a feel for the basics of developing software with JavaFX.  The book is written in a conversational style with plenty of diagrams and images. The authors also point out areas of interest and places where things don’t work the way a Java developer might expect -- like not being able to modify the contents of a sequence that’s passed into a function because it’s passed in by value, not by reference.

Review

Essential JavaFX is a well written introduction to JavaFX. It is written in a conversational style and there's lots of diagrams and screen shots to break up the text and show you the results of executing the sample code. As the title suggests, the purpose of this book is to get you familiar with the key parts of JavaFX so you can begin writing applications in it right away.

Chapter 1: Getting Started with JavaFX
You'll start with a brief look a the history of JavaFX followed by a briefer description of the three components of the “JavaFX Bundle”; the JavaFX SDK (compiler, runtime tools, and libraries), the NetBeans IDE (their preferred tool for editing, compiling, running and debugging JavaFX code), and the JavaFX Production Suite (a set of tools that let graphics designers export their work so JavaFX developers can use it directly).

Next, you'll learn how to download and install the JavaFX Bundle. The chapter ends by walking you through the steps to create a JavaFX project, entering some code, and running it.
 
Chapter 2: A Taste of JavaFX
Chapter two introduces a simple but potentially useful application (a guitar tuner) to give you a better feel for what’s involved in writing JavaFX code. This allows the authors to introduce some of the language constructs and philosophy in the context of creating an application so you can see how it all applies.

As you read through the chapter, you’ll see code fragments followed by images showing the results of executing the code. Sadly the images are not in color, though the grayscale they use is adequate for most of the images.

The chapter ends by presenting the complete source code for the guitar tuner application and descriptions of the various parts. While we’ve seen parts of it throughout the chapter, as well as other bits of sample code) it’s nice to see it all in one place so you can read it and see for yourself how well you are picking up the language.

Chapter 3: JavaFX Language

In chapter three you get to go deeper into the details of the JavaFX scripting language including declaring variables (using both the built-in and Java data types), pseudo-variables, expressions, operators, sequences (JavaFX’s version of arrays), writing functions and classes, and working with mixins, binding, and triggers.

The authors take some time and space to examine and explain the language details, and they point out the things that might trip up experienced Java programmers.
 
Chapter 4: Graphical Objects
Sun promotes JavaFX as making it easy to create applications with great graphics, and in this chapter you'll learn the basics of the JavaFX graphics system, including the Stage, Scene, and Node classes, how to work with Mouse and Keyboard event handlers, and how to deal with the Cursor.

Built in simple Shape classes like Line, Rectangle, Circle, ElipseArc, and Polygon are covered as well as the more complex Shapes like QuadCurve, CubicCurve, PolyLine, SVGPath and Text classes, and the composite shape classes ShapeIntersect and ShapeSubtract.

The chapter ends with a look at Paths, Layout components, and some of the classes used for managing the two dimensional coordinate space within a scene; Point2D, and Rectangle2D.

Chapter 5: User Interface Components
This chapter covers both types of user interface components available in JavaFX; native components and wrapped Java Swing components.  There’s a nice example showing how to incorporate the Swing-based components into an application.

The look of a JavaFX component (called its “skin”) is determined by an associated CSS file. The chapter ends by walking you through the creation of a skinnable TextButton component which is added to the example application as part of a popup dialog box.

Chapter 6: Anatomy of a JavaFX Application
In this chapter you get a quick look at how to use object-oriented design principles to create a simple JavaFX application. In the course of creating the application, you’ll also get a feel for how easy it is to use the graphics capabilities of JavaFX (like gradients, drop shadows, and animation) to improve the user experience of an application.
 
Chapter 7: Animation
The authors refer to animation as the “heart and soul of JavaFX”, and chapter seven shows you how to create simple animations in JavaFX using Timelines, Keyframes and interpolation. After that you'll create more complex animations that include groups of scene graph nodes, transitions (move, scale, fade, and rotate), animating a node along a path using PathTransitions, and using the SequentialTransition and ParallelTransition classes to combine two or more PathTransitions.

Chapter 8: Working with Images
Chapter eight covers the Image and ImageView components and the things you can do with them using JavaFX including scaling, animation, transformations, and effects. In the examples you'll learn how to load and display a single image, perform transformations like scaling, rotation, fading, and adding a reflection to it. Expanding on that, you''ll create a simple gallery that displays multiple images at the same time. In the final example, you'll create a “photo carousel” that displays multiple images traveling along a circular path. By scaling the size of the images as they move along the circle, you make them appear to be moving nearer and farther away, which gives it a nice three-D feeling.

Chapter 9: Web Services
This chapter shows you how to access Web Services using JavaFX. You learn how to use the PullParser to work with data in XML or JSON formats, and how to use the HTTPRequest class to make HTTP requests. You'll see how to take the photo carousel from chapter 8 and connect it to Flickr as an image source.
 
Chapter 10: Mobile Applications
The last chapter covers what you need to know about creating mobile applications. You’ll learn how to identify that the application is running in a mobile environment, the screen’s orientation, and how to be notified that the orientation has changed. You'll see how to apply this by giving the photo carousel application a makeover to make it “mobile ready.” The chapter ends by taking a sample application from chapter seven and reworking it for the mobile environment.

Published at DZone with permission of its author, Burk Hufnagel.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Jilles Van Gurp replied on Fri, 2009/09/25 - 12:12pm

Is anyone actually using JavaFX in production? I've never encountered anything JavaFX except for the really shitty & underwhelming demoes Sun provided two years ago.

Really, what's the point of JavaFX or client side Java in general now that Oracle is scooping up what remains of Sun and world + dog is using java to build nice server side applications on top of HTML, AJAX, Flash, etc.?

Vladimir Vivien replied on Fri, 2009/09/25 - 12:53pm

Very few production grade stuff since javafx is but a year old in its current incarnation.  There's a social music site reportedly built their music mixer with JavaFX http://blogs.sun.com/javafx/entry/cloud_based_recording_studio_with .

Thierry Milard replied on Fri, 2009/09/25 - 1:41pm in response to: Jilles Van Gurp

Well perhaps javaFx is a good thing to have html-embedded rich appication.

Just like flash is a good thng to have html-embedded video, javaFx is or will be a good thing to have graphical or business rich application.

In clear : see more javaFx as a Flash competitor

 

Rogerio Liesenfeld replied on Fri, 2009/09/25 - 3:10pm

It's good to see several books on JavaFX already published, but I am afraid the technology is still too immature and changing too much so, personally, I won't be buying such books for now; later, definitely yes.

JavaFX will succeed in the next few years, I believe, because Oracle will invest in it and also because there is real demand out there for a Swing successor. (From my part, I will be porting a personal Swing-based app to JavaFX as soon as JavaFX 1.5 is out.)

For the same reasons above, Scala will not succeed, IMO. It got no big company behind it, and provides no really compeling technical reason to switch from current choices (Swing, GWT). Just being a better programming language is not enough.

Burk Hufnagel replied on Mon, 2009/09/28 - 4:52pm in response to: Jilles Van Gurp

 Jilles,

I guess it depends on what you mean by "production". I know that sounds weasel-ish so let me clarify a little. I know that Sun said they were doing the interface for the Java App Store using JavaFX, but it's still in Beta so that definitely doesn't count, but what about sites like http://javafx.com/ - the demos there look pretty good to me. Then again, does that count as being "production"?

Thanks for the feedback,
Burk

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.