This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Head First Java problem

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Wondered if anyone had ever come across this problem...

I'm working my way through the Head First Java book, and am putting together the music player. Reached the third part of that, combining blobs and music. what I've found is that I get no sound (yep I have checked the volume . Also I only get a window and no blobs. When I use the downloaded code I get the blobs but still no music. I'm puzzled as I can't see any obvious typos in my code, included below in case you guys can.

Cheers,
Pete.

 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a bad idea:

} catch (Exception e) { }


How will you know if there are problems? At least print something to the console.
 
Marshal
Posts: 75650
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
. . . and welcome to JavaRanch
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I compiled this same text and ran it. I was getting the music but a blank frame.

I wrote a program for this on my own with frequent updates from the book - without copying directly- and i get music with a single rectange that does not change with the note.

Some technical guru ought to guide us to find the problem. Anyone??

sujani
 
Ranch Hand
Posts: 180
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try overriding the paintComponent method by changing

to
 
Greenhorn
Posts: 14
Netscape
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm guessing this is all old news, but you may want to try to change the paintComponent lines to:


I just compiled and ran a slightly different version and it all seems to work fine. If you'd like to try it I will post it below.
Did the first two iterations work on the command line? I'm just learning also, but hopefully this will help.
I added a little code to the catch statements also.

I was also having the closing problem as discussed in some other forum topics, and so add an EXIT_ON_CLOSE statement to the setUpGui method.

Good Luck,
Matt

 
Live ordinary life in an extraordinary way. Details embedded in this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic