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
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
series of initialization steps occur, with many opportunities for
customization of the sort described in the next section:
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
For each cue,
) 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
javax.swing.plaf.metal.sounds package ...