import java.applet.*; import java.awt.*; import java.awt.event.*; public class PlaySoundApplet extends Applet implements ActionListener { Button play,stop; AudioClip audioClip; public void init() { play = new Button(" Play_Loop "); add(play); play.addActionListener(this); stop = new Button(" Stop_Play "); add(stop); stop.addActionListener(this); audioClip = getAudioClip(getCodeBase(), "Play_Sound.wav"); } public void actionPerformed(ActionEvent ae) { Button source = (Button)ae.getSource(); if (source.getLabel() == " Play Loop ") { audioClip.play(); } else if(source.getLabel() == " Stop Play ") { audioClip.stop(); } } }
OUTPUT:
We already discussed about the execution procedure of an applet in Java Applet Program To Design a Login Window