O'Reilly logo

Java Swing, 2nd Edition by Brian Cole, James Elliott, Marc Loy, Robert Eckstein, Dave Wood

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

Auditory Feedback Actions

A general framework for providing auditory feedback in response to user interface actions was introduced in Version 1.4. BasicLookAndFeel (as described in Chapter 26) provides most of the support, and other L&Fs extend it in order to actually play appropriate sounds. As of SDK 1.4.1, none of the standard L&Fs turn on any sounds by default. Comments in the source code indicate that this has been delayed due to sound bugs.

The list of possible actions to which a sound can be assigned is contained in a special ActionMap managed by BasicLookAndFeel. It is protected since only subclasses are likely to need access to it. They can obtain (or create, if necessary) the map by calling getAudioActionMap( ). The keys in this map are shown in Table B-45. The values are Actions that produce appropriate sounds when they are performed. The standard L&Fs define inner AudioAction classes for this purpose.

Table B-45. Audio actions defined by BasicLookAndFeel

CheckBoxMenuItem.commandSound

InternalFrame.closeSound

InternalFrame.maximizeSound

InternalFrame.minimizeSound

InternalFrame.restoreDownSound

InternalFrame.restoreUpSound

MenuItem.commandSound

OptionPane.errorSound

OptionPane.informationSound

OptionPane.questionSound

OptionPane.warningSound

PopupMenu.popupSound

RadioButtonMenuItem.commandSound

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