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
With the release of JavaFX 2.0 the question for many Java developers is whether it's time to start transitioning Swing applications to this new UI paradigm, and what better way to find out than by a hands-on exercise? In this three-part tutorial, Jeff Friesen walks through the process of refactoring an example Swing-based notepad editor application to its JavaFX 2 equivalent.
JavaFX 2 is a user interface library and platform for creating and running modern Java application UIs that feature rich graphics, animation, media, controls, and more. It's also a toolkit for deploying JavaFX applications, meaning any Java application that features a JavaFX UI. A JavaFX application can be deployed standalone, launched via Java Web Start, or embedded in a web page.
This article serves as a practical introduction to JavaFX 2, and is geared to developers experienced with Swing-based user interface (UI) development. By refactoring a Swing application, you'll familiarize yourself with some of the most useful features of JavaFX 2. You'll have the opportunity to try it on for size. And you'll get some practice in refactoring Swing apps to JavaFX -- which could come in handy if JavaFX 2 turns out to be the next-generation Java development platform that Oracle clearly hopes it will.
Oracle has been pushing JavaFX 2 as the next-generation platform for Java, but does that mean it's time to jump from Swing to JavaFX? Refactoring a Swing demo app to JavaFX is one way to find out.
This first part of the article is an overview of a Swing demo application, a text editor called JPad. Experienced Swing developers can probably give the architecture a glance, then move on to refactoring the app for JavaFX in Part 2 and Part 3. For those less experienced with Swing, Part 1 offers valuable insight into client-side application development, which you'll probably need in order to follow the refactoring examples.
Oracle released JavaFX 2.0 beta in May 2011 and declared it production-ready in October of that same year. The most recent version, JavaFX 2.0.2, was released in December 2011 with some bug fixes and minor features added. Examples in this article are based on JavaFX 2.0.2.
Let's start with a review of new features in JavaFX 2, some of which you'll encounter in the refactored JPad architecture.
JavaFX 2 differs significantly from previous versions, and one of the biggest changes is the deprecation of JavaFX Script. JavaFX developers are free to program in Java code, and may also experiment with JVM scripting languages such as Groovy or Scala. Java code is more verbose than JavaFX Script, but there's hope that Java 8's support for lambda expressions in the Java language will bring improvements.
The following JavaFX Script language features have been replaced with Java API equivalents:
More from JavaWorld