• 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

How many times painComponent(g) is called?

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I the method painComponent(g) is called is it called once or multiple times if I don't use repaint???=/
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is called whenever Swing decides that the component needs to be repainted. That might happen when you minimize and then restore your application, or temporarily hide it by displaying some other application over it, and so on. You can signal that it needs to be repainted by calling repaint() on the component, but otherwise you aren't in control of the process.

So your code should be prepared to display the correct output every time that paintComponent is called.
 
Bobby Marvikuan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:It is called whenever Swing decides that the component needs to be repainted. That might happen when you minimize and then restore your application, or temporarily hide it by displaying some other application over it, and so on. You can signal that it needs to be repainted by calling repaint() on the component, but otherwise you aren't in control of the process.

So your code should be prepared to display the correct output every time that paintComponent is called.


cheers helped a lot!(:
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
painComponent(g) gets called everytime the bully hits you
 
reply
    Bookmark Topic Watch Topic
  • New Topic