Doubt regarding the Dysplasia() and Repaint() methods

Asked

Viewed 32 times

2

What is the function of the methods .dispose() and repaint() using Graphics in Java?

1 answer

2


If you are referring to the method dispose() class Graphics, as stated in the documentation itself, it serves to free the system resources that this class uses when you create an instance of it.

Think that, since this class has an importance based on creating everything you see on the screen, it can consume many system resources as well as having several associated instances. Still according to the documentation, the JVM garbage collector can usually handle this, but giving dispose(), you can guarantee with a little more efficiency that these resources used will, in fact, be released. Remembering that an instance of Graphics can no longer be used after this method is called.

Already the method repaint(), as already explained in this other answer, is intended to warn that the screen needs to be redesigned, possibly because some area has undergone some change, and so the screen is all redesigned and is displayed with the updates made on it.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.