Wednesday, December 9, 2009

Full Screen Repaint

If for any reason you have to override getWidth or getHeight methods in a class that extends Canvas, the calls to repaint() might not update the whole display.

And this is an expected behaviour. Check below documentation from API:

public final void repaint()

Requests a repaint for the entire Canvas. The effect is identical to

repaint(0, 0, getWidth(), getHeight());


If you want to always update the whole display when calling repaint() add the following method to your class:


public void repaint() {
super.repaint(0, 0, super.getWidth(), super.getHeight());
}

No comments: