• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Applet doesn't repaint properly

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This applet doesn't repaint properly after it's minimized or another window gets on top of it.




Don't I need a repaint or update method here?
 
Rancher
Posts: 43009
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You shouldn't use the paint method with Swing, but the paintComponent method; paint is for AWT components.
 
Steve O Smith
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow. That's the method used in the textbook for my intro to compsci class. The examples in the book have the same problem.

Didn't the author think to, oh I don't know, google this or ask on a forum? Jeez.

Thanks. I'll look into paintcomponent().
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JApplet doesn't have a paintComponent(...) method. Custom painting in Swing is best done in an extended JComponent or JPanel, by overriding the paintComponent(...) method mentioned by Ulf. More here: Lesson: Performing Custom Painting.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!