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.

Page 2 of 2 FirstFirst 12
Results 26 to 33 of 33

Thread: Adding sound to program.

  1. #26
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Adding sound to program.

    I don't think so. Post the print out here and I'll show you.

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

    Default Re: Adding sound to program.

    run this=Bluemoon.PlaySound$1@1d23e75

  3. #28
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Adding sound to program.

    run this=Bluemoon.PlaySound$1@1d23e75
    The full class name is Bluemoon.PlaySound$1
    The $1 is for the inner class that run is in.
    If run were in the PlaySound class, the output would be something like this:
    run this=Bluemoon.PlaySound@1d23e75

    Notice no $1

    If you look in the folder with the class files you will see two class files:

    12/21/2011 01:53 PM 4,555 PlaySound$1.class <<<<<<< The inner class with run()
    12/21/2011 01:53 PM 1,379 PlaySound.class <<<< The PlaySound class

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

    Default Re: Adding sound to program.

    I'm a noob but how would this help me? Would i change
    PlaySound s = new PlaySound();
    to
    PlaySound$1 s = new PlaySound$1();
    Because i tried that and it didn't work.

  5. #30
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Adding sound to program.

    In the PlaySound class, is there a variable/reference to the inner class that has the run() method?
    Is it public? Can you use it from another class?

    Think about what this statement does and how it is put together:
    System.out.println()

    <Classname>.<static variable>.<methodname>()
    Last edited by Norm; December 21st, 2011 at 02:15 PM.

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

    Default Re: Adding sound to program.

    No how would i make that variable?

  7. #32
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Adding sound to program.

    how would i make that variable?
    The PlaySound class has it.

    Where did you copy the code from? It was not written to do what you want. It should be rewritten for you to be able to use it as you are trying.

    Take the code out of the run() method and make a new method that plays sounds. Get rid of the Thread and Runnable stuff.

  8. The Following User Says Thank You to Norm For This Useful Post:

    Archibold9 (December 21st, 2011)

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

    Default Re: Adding sound to program.

    Okay thanks for your help. I'll go do it now >.<

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Recording Sound
    By mulligan252 in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: July 1st, 2014, 12:45 AM
  2. Adding sound to a game application
    By Shaybay92 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: September 13th, 2011, 07:56 AM
  3. Paint program adding classes to main method class
    By Maxfmc in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 15th, 2011, 07:01 PM
  4. [SOLVED] Problem with a tutorial program(Adding the answer of two squared numbers together)
    By Melawe in forum What's Wrong With My Code?
    Replies: 20
    Last Post: April 7th, 2010, 09:03 AM
  5. need help with Timer and sound
    By amahara in forum AWT / Java Swing
    Replies: 4
    Last Post: February 18th, 2010, 12:22 PM