Steve
Steve Luke wrote:One way would be to get the bounds of the rectangle before the move, move the rectangle, repaint both the original and the new area.
luck, db
There are no new questions, but there may be new answers.
Darryl Burke wrote:Never use getGraphics() of a Component.
Get the Rectangle before the move, probably in mousePressed(...)
Get the Rectangle after teh move, probably in mouseReleased(...) or maybe in mouseDragged(...)
Add one Rectangle to the other (see the API for java.awt.Rectangle)
Repaint the union of the two Rectangles.
But don't do any of that if you don't actually have a performance problem. Premature optimization is evil. Simple code that performs adequately is always more readable and maintainable.
Darryl Burke wrote:Post an SSCCE as maybe we're not talking about the same thing.
luck, db
There are no new questions, but there may be new answers.
Darryl Burke wrote:Jay, did you read the SSCCE page? You've posted code that includes setting the LaF to Nimbus and who knows what else that isn't relevant to the problem. If there is a problem at all -- are you really experiencing a visible, noticeable performance hit?
edit And you're still using getGraphics(). I already told you that's not correct.
Please go through the Lesson: Performing Custom Painting.
Darryl Burke wrote:Jay, did you read the SSCCE page? You've posted code that includes setting the LaF to Nimbus and who knows what else that isn't relevant to the problem. If there is a problem at all -- are you really experiencing a visible, noticeable performance hit?
edit And you're still using getGraphics(). I already told you that's not correct.
Please go through the Lesson: Performing Custom Painting.
luck, db
There are no new questions, but there may be new answers.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |