Playing sound when showing popup in Swing?
I have a frame which pops up whenever an event occurs.
Whenever that frame pops up, I want开发者_Go百科 a sound to be played.
How can I do that in Swing?
A very simple solution is using Toolkit.getDefaultToolkit().beep();
Check this question in this same site: How can I play sound in Java?
Subclass JDialog or similar and on the constructor/setVisible method of the derived class play a sound with one of the fore mentioned methods.
精彩评论