*
The moose likes Beginning Java and the fly likes null pointer again! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "null pointer again!" Watch "null pointer again!" New topic
Author

null pointer again!

Syamsul Hussin
Ranch Hand

Joined: Feb 09, 2003
Posts: 59
Hi, I really dont know why null pointer is thrown in this code:-

the program is supposed to display a fill oval with color according to the selection made by user from the checkbox. the graphics object for canvas seems to be the problem again, although this time i've put it this way:-

The exception thrown is:-


----------------------------------<br />SCJP 1.4
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
You're trying to get the Graphics context of something that hasn't even been displayed yet. Move the code to get the Graphics context to after where you display the frame.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Syamsul,
He dude, you had the same problem here null pointer?. Haven't you ever heard the saying Once bitten, twice shy?
Michael Morris


Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: null pointer again!