Results 1 to 6 of 6
  1. #1
    N00Bie is offline Senior Member
    Join Date
    Feb 2011
    Posts
    107
    Rep Power
    0

    Default AWT / Swing - play a sound

    Hi,
    Doing a Google search for "java play sound" is either getting me entire java players or sound in damn Applets (something I have not learned as yet).

    Does anyone have a simple program where you click a JButton and a sound plays? (For AWT/Swing - NOT Applets please)

    Nothing fancy, one button -> click-> play a damn sound.

    Thanks!

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,784
    Rep Power
    7

    Default

    The code in the Applet example should be fine.

  3. #3
    N00Bie is offline Senior Member
    Join Date
    Feb 2011
    Posts
    107
    Rep Power
    0

    Default

    This is the one I found that looks decent:
    http://www.java.happycodings.com/Java_Sound/code5.html
    Last edited by N00Bie; 02-21-2011 at 02:34 AM. Reason: EDIT: Wrong URL

  4. #4
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,784
    Rep Power
    7

    Default

    What do you want me to do about it?

    You do realise that sounds are audio and that applets/gui are visual. They have nothing to do with each other. All you have to do is find the code that relates to playing sounds. Ignore all the visual stuff.

  5. #5
    N00Bie is offline Senior Member
    Join Date
    Feb 2011
    Posts
    107
    Rep Power
    0

    Default

    What do you want me to do about it?
    Nothing, just showing you if you are curious as to what I am talking about.
    Quote Originally Posted by Junky View Post
    You do realise that sounds are audio and that applets/gui are visual. They have nothing to do with each other. All you have to do is find the code that relates to playing sounds. Ignore all the visual stuff.
    Since I have no knowledge of Applets, I am a bit apprehensive in mucking around in that code...

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by N00Bie View Post
    Since I have no knowledge of Applets, I am a bit apprehensive in mucking around in that code...
    It's just another class, and similar to others, you create an object from it and call its methods.

Similar Threads

  1. Play soundclip and generate"wind" like sound
    By diablo2070 in forum New To Java
    Replies: 5
    Last Post: 03-13-2011, 08:47 PM
  2. javax.sound play midi
    By Dennis in forum Advanced Java
    Replies: 6
    Last Post: 06-08-2010, 04:59 PM
  3. Why doesnt the sound play when I change the path?
    By ProGenius in forum New To Java
    Replies: 10
    Last Post: 12-22-2009, 04:58 PM
  4. Make sound play in a java application
    By lenny in forum AWT / Swing
    Replies: 2
    Last Post: 08-13-2007, 11:45 AM
  5. Play sound and Video in a Mobile Phone
    By luisarca in forum Sun Java Wireless Toolkit
    Replies: 2
    Last Post: 05-23-2007, 10:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •