• Post Reply Bookmark Topic Watch Topic
  • New Topic

How many times painComponent(g) is called?  RSS feed

 
Bobby Marvikuan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • 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???=/
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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!(:
 
Randall Twede
Ranch Hand
Posts: 4683
8
Java Scala
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
painComponent(g) gets called everytime the bully hits you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!