• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with JPanel paintComponent()  RSS feed

 
kwame Iwegbue
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In "Head First Java" this method is described as one that "never needs to be called" ...not sure what this means. does it mean that you won't need to use a main method?

In that case, why won't this run




...it compiles, but at runtime I'm getting Exception in thread main "java.lang.NoSuchMethodError"

please help this extreme beginer...
[ July 02, 2005: Message edited by: kwame Iwegbue ]
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does it mean that you won't need to use a main method?

In that case, why won't this run

if you keep reading on you'll see another class that uses this panel and then, has a main so that you can actually see it (this panel has no main hence your error msg)
 
kwame Iwegbue
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you so much.
...why didn't i think of that!?
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by kwame Iwegbue:
In "Head First Java" this method is described as one that "never needs to be called" ...not sure what this means.

[ July 02, 2005: Message edited by: kwame Iwegbue ]


This wording might be a little misleading because ALL methods need to be called before they actually do anything. However, the idea here is that YOU never call paintComponent() directly yourself. It is called by the Swing event mechanism when it decides that the GUI needs to repaint itself. Typically this happens if you cover up your window with another program and then bring it to the front again.

If you have more questions about writing GUI programs with Swing, you should mosey over to our GUI forum. You will be more likely to get help there since that's where the experts in this area hang out.

Regards,

Layne
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!