Ad Code

Difference in the paint() and repaint() methods?


What is the difference between the paint() and repaint() methods?

The paint method is where actual painting occurs. If you want to change the way a Component is drawn, you should override this method.

The repaint method typically just tells your Component that it should call its paint method as soon as it can. This is the method you should call to force a Component to update itself. The Java API warns not to ever directly call the paint method, mostly for efficiency reasons.
Reactions

Post a Comment

0 Comments