After learning that dispose()
should be called on Graphics
/Graphics2D
object after use, I went about changing my game to incorporate t
The thing is that the Graphics
context you are using in paintComponent
is created and provided by the caller (the framework), which is also responsible for disposing of it.
You only need to dispose of Graphics
when you actually create it yourself (for example by calling Component.getGraphics()
). In your case, you're not creating it, you're just casting it, so do not call dispose in this case.
Because .dispose()
releases your resources. Yes, everything.