• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

playing sounds when button is pressed

Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to play a sound when a button is selected. I am using the following code to do it:

JRadioButton soundBT = new JRadioButton();
soundBT.addActionListener(new ActionListener() {
public void actionPerormed(ActionEvent e) {
if (soundBT.isSelected()) {
URL soundUrl = getClass().getResource(EOF_SOUND);
AudioClip audioClip = Applet.newAudioClip(soundUrl);

However, the sound is inconsistent. Sometimes it is played, other times it is played partially, and sometimes it is not played at all. Any suggestions would be helpfull. Thanks.

Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!