public void stretch ( Point p ) { lastPt . x = stretchedPt . x ; lastPt . y = stretchedPt . y ; stretchedPt . x = p . x ; stretchedPt . y = p . y ; Graphics2D g = ( Graphics2D ) component . getGraphics ( ) ; if ( g != null ) { try { g . setXORMode ( component . getBackground ( ) ) ; if ( firstStretch == true ) firstStretch = false ; else drawLast ( g ) ; drawNext ( g ) ; } finally { g . dispose ( ) ; } // try } // if }
Erase the last rectangle and draw a new one from the anchor point to this point .