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.


>> REGISTER NOW TO START POSTING


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

Results 1 to 9 of 9

Thread: Creating a class to play sounds.

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Creating a class to play sounds.

    I have a main GUI JFrame class and i want to play .wav sounds when a button is pressed. I've configured everything in the GUI and now i just need to make a sound class which plays a song, located in the file which the jar file will be in. How would i go about doing this?

    My main class is called Bluemoon.
    The sound class i've started is called PlaySound.
    Last edited by Archibold9; December 21st, 2011 at 04:07 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Creating a class to play sounds.

    You could copy the code out of your post on this thread:
    http://www.javaprogrammingforums.com...html#post53241

  3. #3
    Junior Member
    Join Date
    Dec 2011
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Creating a class to play sounds.

    You told me it was wrong D: I'm not good at sounds in java.....

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Creating a class to play sounds.

    The code plays sounds OK. The problem is the way the code is inside of an inner class.

  5. #5
    Junior Member
    Join Date
    Dec 2011
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Creating a class to play sounds.

    How would i fix that..? Yes. I am a noob.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Creating a class to play sounds.

    This project is past your knowledge. You need to learn more about how to write classes and methods.
    Save this project for later. Go back and work on the basics.

  7. #7
    Junior Member
    Join Date
    Dec 2011
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Creating a class to play sounds.

    I know how to do this.. Its sound that confuses me.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Creating a class to play sounds.

    The code you posted works. Repackage it in another method and it should work there.
    Why do you want to muck around with code that works. Leave it alone.

  9. #9
    Junior Member
    Join Date
    Dec 2011
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Creating a class to play sounds.

    There. Got it working.

Similar Threads

  1. Creating and implementing class for creating a calendar object
    By kumalh in forum Object Oriented Programming
    Replies: 3
    Last Post: July 29th, 2011, 08:40 AM
  2. [SOLVED] Class Creating Help
    By pitchblack in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 1st, 2011, 11:25 PM
  3. Sounds to play during action performed
    By smithyboy in forum Object Oriented Programming
    Replies: 2
    Last Post: November 20th, 2010, 04:16 PM
  4. Help with creating a class
    By cdawg_2010 in forum Loops & Control Statements
    Replies: 4
    Last Post: November 1st, 2010, 07:04 AM
  5. image and sounds mp3 database
    By Stefan_Lam in forum JDBC & Databases
    Replies: 0
    Last Post: May 7th, 2010, 05:30 AM