Is using (in the paint method) g.clearRect() the correct way to clear the screen? It's working but I don't know if there is a better way. . google says it is supposed to clear automatically when update is called but that doesn't seem to happen.
BestJewSinceJC 700 Posting Maven
Recommended Answers
Jump to PostIf you consider that the component generally starts with a cleared surface of the background color, it's often unnecessary to use clearRect() or fillRect() to clear out the background, but if you are maintaining an image reference for purposes of buffering some updates then you would need to clear that …
Jump to PostYes, sorry, I guess I wasn't very clear. I had a scenario like what Vernon mentions above in mind when I said that the component starts with a cleared background. I was assuming a call to super.paintComponent() before any other painting.
All 6 Replies
kvprajapati 1,826 Posting Genius Team Colleague
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
BestJewSinceJC 700 Posting Maven
VernonDozier 2,218 Posting Expert Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
BestJewSinceJC 700 Posting Maven
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.