aspose file tools*
The moose likes Beginning Java and the fly likes Head First Java problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Head First Java problem" Watch "Head First Java problem" New topic
Author

Head First Java problem

Pete Blamire
Greenhorn

Joined: Oct 22, 2009
Posts: 1
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.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41508
    
  53
This is a bad idea:
} catch (Exception e) { }

How will you know if there are problems? At least print something to the console.


Ping & DNS - my free Android networking tools app
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38353
    
  23
. . . and welcome to JavaRanch
sujani Koya
Greenhorn

Joined: Jul 31, 2011
Posts: 1
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
Ogeh Ikem
Ranch Hand

Joined: May 13, 2002
Posts: 180
Try overriding the paintComponent method by changing

to
Matt Hanrahan
Greenhorn

Joined: Jul 09, 2011
Posts: 14

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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Head First Java problem