• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem with JPanel paintComponent()

 
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much.
...why didn't i think of that!?
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic