Java Reference
In-Depth Information
JavaFX is easier to use—it provides one API for GUI, graphics and multimedia
(images, animation, audio and video), whereas Swing is only for GUIs, so you
need to use other APIs for graphics and multimedia apps.
With Swing, many IDEs provided GUI design tools for dragging and dropping
components onto a layout; however, each IDE produced different code. JavaFX
Scene Builder (Section 25.2) can be used standalone or integrated with many
IDEs and it produces the same code regardless of the IDE.
Though Swing components could be customized, JavaFX gives you complete
control over a JavaFX GUI's look-and-feel (online Chapter 26) via Cascading
Style Sheets (CSS).
JavaFX was designed for improved thread safety, which is important for today's
multi-core systems.
JavaFX supports transformations for repositioning and reorienting JavaFX com-
ponents, and animations for changing the properties of JavaFX components over
time. These can be used to make apps more intuitive and easier to use.
JavaFX Version Used in This Chapter
In this chapter, we use JavaFX 2.2 (released in late 2012) with Java SE 7. We tested the
chapter's apps on Windows, Mac OS X and Linux. At the time of this writing, Oracle was
about to release JavaFX 8 and Java SE 8. Our online Chapters 26 and 27—located on the
book's companion website (see the inside front cover of this topic)—present additional
JavaFX GUI features and introduce JavaFX graphics and multimedia features in the con-
text of JavaFX 8 and Java SE 8.
25.2 JavaFX Scene Builder and the NetBeans IDE
Most Java textbooks that introduce GUI programming provide hand-coded GUIs—that
is, the authors build the GUIs from scratch in Java code, rather than using a visual GUI
design tool. This is due to the fractured Java IDE market—there are many Java IDEs, so
authors can't depend on any one IDE being used.
JavaFX is organized differently. The JavaFX Scene Builder tool is a standalone JavaFX
GUI visual layout tool that can also be used with various IDEs, including the most popular
ones—NetBeans, Eclipse and IntelliJ IDEA. JavaFX Scene Builder is most tightly inte-
grated with NetBeans, 1 which is why we use it in our JavaFX presentation.
JavaFX Scene Builder enables you to create GUIs by dragging and dropping GUI
components from Scene Builder's library onto a design area, then modifying and styling
the GUI—all without writing any code. JavaFX Scene Builder's live editing and preview
features allow you to view your GUI as you create and modify it, without compiling and
running the app. You can use Cascading Style Sheets (CSS) to change the entire look-
and-feel of your GUI—a concept sometimes called skinning . In online Chapter 26, we'll
demonstrate the basics of styling with CSS.
In this chapter, we use JavaFX Scene Builder version 1.1 and NetBeans 7.4 to create
two complete introductory JavaFX apps. Online Chapters 26-27 use JavaFX Scene
Builder 2.0, which was about to be released when this topic went to publication.
1. http://www.oracle.com/technetwork/java/javafx/tools/index.html .
 
 
Search WWH ::




Custom Search