The MultiLookAndFeel
Before we get into creating our own
L&F, we’ll take a quick detour to explore the
MultiLookAndFeel. This is the L&F that allows
accessible interfaces to be incorporated into Swing applications. It
can also be used to add things like audio sound effects, support for
automated testing, etc.
By this point, you’re probably at least aware of the concept of accessibility as it applies to JFC and Swing. If you read the previous chapter, you’re aware of more than just the concept. The last piece of the accessibility puzzle is Swing’s multiplexing L&F support.
The idea behind the MultiLookAndFeel is to allow
multiple L&Fs to be associated with each component in a
program’s GUI, without the components having
to do anything special to support them. By allowing multiple
L&Fs, Swing makes it easy to augment a traditional L&F with
auxiliary L&Fs, such as speech synthesizers or braille
generators. Figure 26.9 gives a high-level view of
how this might work.

Figure 26-9. The multiplexing look-and-feel
In this diagram, we show a JButton in a
multiplexing UI environment. The button’s
UI delegate is actually a
MultiButtonUI, which is contained in the
javax.swing.plaf.multi package. This is a special
delegate that can support any number of additional
ButtonUI objects. Here, we show the default
UI delegate (MetalButtonUI) and
two (hypothetical) auxiliary delegates,
AudioButtonUI and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access