O'Reilly logo

Swing Hacks by Chris Adamson, Joshua Marinacci

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

322
|
Chapter 8, Rendering
#64 Turn the Spotlight on Swing
HACK
The Metaphor
If you have ever been to a comic show, to the theatre, or to the circus,
you’ve probably noticed how spotlights are used to move your focus to a
particular location on the stage. A search operation can be compared to a
theatre stage, where actors have been replaced by search results. You just
need to get the user to focus on the right location.
Take a look at an example application, shown in Figure 8-12, which dis-
plays a predefined set of books and lets you search for one or more of them
by entering a search query in the text field at the bottom of the window.
Since the application is just a demo, you can only enter one of the following
queries: books, sci-fi, adams, and pratchett. Each query, when validated by
the Enter key, will find the related books and spotlight them, as shown in
Figure 8-13.
Figure 8-11. All the problems provoked by mixing Java3D and Swing have been solved
Turn the Spotlight on Swing #64
Chapter 8, Rendering
|
323
HACK
Figure 8-12. The bookshelf application must let the user search for books
Figure 8-13. Searching for “sci-fi” highlights Science Fiction books

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required