wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes The GUI Thread. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "The GUI Thread." Watch "The GUI Thread." New topic
Author

The GUI Thread.

netharam ram
Ranch Hand

Joined: Aug 09, 2001
Posts: 202
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The GUI Thread.
 
Similar Threads
why is it so??
Stopping an audio file
Apple + sound + permission
Hey! Dont ne One know About Java SOUND???!!
playing sounds when button is pressed