
316
|
Chapter 8, Rendering
#63 Add a Third Dimension to Swing
HACK
H A C K
#63
Add a Third Dimension to Swing
Hack #63
User interfaces have stuck to 2D drawing for many years. Today, Swing and
Java3D give you a chance to go one step further and add 3D widgets to your UI.
Have you ever wondered how to add nice 3D components into your Swing
applications? Java3D is a free API provided by Sun Microsystems for Linux
and Windows, and by Apple for Mac OS X, that lets you create 3D scenes.
Although well documented, Java3D seems impossible to use with Swing—at
least at first glance.
The Problems with Java3D
Imagine you decided to create a new, astonishing application called
AmazonPick that would let the user search for books on the Amazon.com
store. Your eye-candy user interface would even display the currently
selected book as a 3D object; whenever the user selects another book, the
3D object would flip to show the new cover on its opposite side. Figure 8-8
shows how the application should look.
Figure 8-8. AmazonPick shows books as full 3D objects