O'Reilly logo

Java Swing by Dave Wood, Marc Loy, Robert Eckstein

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

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.

The multiplexing look-and-feel

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 ...

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