My application plays a wav file on wrong password prompted from an InputDialog. The Code is:
import java.applet.Applet;
import java.applet.AudioClip;
import java.io.PrintStream;
import java.net.URL;
public class Snd_Plyr
{
public Snd_Plyr()
{
}
public static void play_snd(final String fname)
{
Thread thread = new Thread(new Runnable() {
public void run()
{
try
{
URL url = new URL("file", System.getProperty("user.dir"), fname);
AudioClip audioclip = Applet.newAudioClip(url);
audioclip.play();
System.out.println("Music Played..");
}
catch(Exception exception)
{
System.out.println("Play:" + exception);
}
}
});
thread.setPriority(10);
thread.start();
}
}
I play using
Snd_Plyr.play_snd("wavfile");
Whenever the user gives a wrong password the sound file is played only for a second & then the main thread starts displaying the InputDialog for the InputDialog is displayd until correct password. write a better code for me Pls.
Happy middling with java.
Netharam.