Skip to Main Content
Java Swing, 2nd Edition
book

Java Swing, 2nd Edition

by Dave Wood, Robert Eckstein, Marc Loy, James Elliott, Brian Cole
November 2002
Intermediate to advanced content levelIntermediate to advanced
1278 pages
38h 26m
English
O'Reilly Media, Inc.
Content preview from Java Swing, 2nd Edition

Auditory Cues

SDK 1.4 introduced a framework for providing auditory cues in response to user interface actions without the complexity of adding an auxiliary L&F. Core support is provided by BasicLookAndFeel through an audio action map (see Table B-45 in Appendix B) that is available for use by subclasses.

It should be noted that, although the framework is in place, none of the standard L&Fs activate any sounds, at least as of SDK 1.4.1. Comments in the source code indicate that the activation has been temporarily disabled due to bugs in sound playback. So although this is an interesting area to watch, and you should feel free to experiment with customizations to activate various sounds, until Sun decides auditory cues are ready to be unleashed, it’s probably best not to rely on them.

With that caveat, here’s how the mechanism is set up. When getAudioActionMap( ) is called for the first time in BasicLookAndFeel, a series of initialization steps occur, with many opportunities for customization of the sort described in the next section:

  1. The UI defaults are consulted to look up the list of sounds to be loaded, under the key "auditoryCues.cueList". This is how Table B-45 gets its values.

  2. For each cue, createAudioAction( ) is called to create the actual Action object that plays the sound. BasicLookAndFeel uses Java Sound to load and play named audio files, and the Metal L&F takes advantage of this mechanism, as shown in Table 26-5 (the files are in the javax.swing.plaf.metal.sounds package ...

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.
Start your free trial

You might also like

Java Threads, 3rd Edition

Java Threads, 3rd Edition

Scott Oaks, Henry Wong

Publisher Resources

ISBN: 0596004087Errata PageSupplemental Content