Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Playing sound each time mouse is clicked (not working)

  1. #1
    Junior Member
    Join Date
    May 2012
    Portland, OR
    Thanked 0 Times in 0 Posts

    Default Playing sound each time mouse is clicked (not working)

    Hey guys, I'm really stumped. I have a chat program and figured it'd be nice to add sound alerts for new messages, but it's not playing sound at all now.
            private class AudioClip extends Thread implements ActionListener{		
    		private InputStream in;
    		private AudioStream as;
    		public void run(){
    		        //Open audio stream
    				in = new FileInputStream("alert.wav");
    				as = new AudioStream(in);
    				Timer time = new Timer(5000, this);
    			}catch(FileNotFoundException e){
    			}catch (IOException e){
    		public void actionPerformed(ActionEvent event) {

    This is in the chat portion and happens each time a message pops up:
    		new AudioClip();						

    EDIT: Got it! I was in a hurry and forgot '.start()' haha
    Last edited by BestSanchez; August 24th, 2012 at 10:24 PM. Reason: SOLVED

Similar Threads

  1. pause while playing sound
    By huddo in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: August 23rd, 2012, 08:33 PM
  2. Playing sound in my nursing program
    By loui345 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 19th, 2012, 08:26 PM
  3. Replies: 9
    Last Post: February 20th, 2012, 04:02 PM
  4. Playing sound in an applet
    By Skyhigh32 in forum Java Theory & Questions
    Replies: 1
    Last Post: June 3rd, 2011, 07:41 AM
  5. playing sound using java
    By sdhilipan89 in forum Java Applets
    Replies: 6
    Last Post: March 25th, 2010, 08:59 AM