question: public void paint ( Graphics g ) { g . setColor ( Color . white ) ; g . fillRect ( 0 , 0 , getWidth ( ) , getHeight ( ) ) ; g . setColor ( Color . BLACK ) ; for ( int stripeX = 0 ; stripeX < getWidth ( ) ; stripeX += CHECKER_SIZE ) { for ( int y = 0 , row = 0 ; y < getHeight ( ) ; y += CHECKER_SIZE / 2 , ++ row ) { int x = ( row % 2 == 0 ) ? stripeX : ( stripeX + CHECKER_SIZE / 2 ) ; g . fillRect ( x , y , CHECKER_SIZE / 2 , CHECKER_SIZE / 2 ) ; } } g . translate ( 0 , translateY ) ; super . paint ( g ) ; }
target:  Paint our container with a checkerboard background. Then set a translation factor on the Graphics object and call the superclass, which will paint the children (e.g, our button) with this  translation.