-1
我想知道下面的函數是如何工作的。通過第一個函數調用, 它只繪製舊方形位置的背景,但第二個函數調用它繪製紅色方形。重繪功能如何工作?
if(CURR_X != x || CURR_Y != y) {
//The square is moving, repaint backgorund
//over the old square location
repaint(CURR_X,CURR_Y,CURR_W+OFFSET,CURR_H+OFFSET);
//Update coordinates
square.setX(x);
square.setY(y);
repaint(square.getX(),square.getY(),
square.getWidth()+OFFSET,square.getHeight()+OFFSET);
}
請參閱[*在AWT和Swing *中繪畫](http://www.oracle.com/technetwork/java/painting-140037.html)。 – trashgod
http://stackoverflow.com/questions/10852897/repaint-method-in-java我想你會發現你在那裏回答 – Koen2K