How would I play whichever sound the user has set for exclamation when I display JOptionPane.WARNING_MESSAGE or the error sound when I display JOptionPane.ERROR_MESSAGE, for example?
How would I play whichever sound the user has set for exclamation when I
Share
Using the links MadProgrammer provided (reposted at the end) as a starting point, here’s what I figured out:
and then just before displaying the JOptionPane:
NB Some sound events like Program Error cannot be accessed this way. A list of accessible sound events is available under the audio-feedback heading on the Windows Desktop Property Support page from Oracle
While this will not work at all on a non-windows o/s, it will not, according to the blog, cause the program to crash on another o/s. I don’t have a
JDKfor my Linux partition yet, ergo I am currently unable to test this.