private void newScreenSize ( Rectangle b ) { boolean sameSize = ( b . width == myBounds . width ) && ( b . height == myBounds . height ) ; if ( debugBounds ) System . out . println ( "NavigatedPanel newScreenSize old= " + myBounds ) ; if ( sameSize && ( b . x == myBounds . x ) && ( b . y == myBounds . y ) ) return ; myBounds . setBounds ( b ) ; if ( sameSize ) return ; if ( debugBounds ) System . out . println ( " newBounds = " + b ) ; // create new buffer the size of the window //if (bImage != null) // bImage.dispose(); if ( ( b . width > 0 ) && ( b . height > 0 ) ) { bImage = new BufferedImage ( b . width , b . height , BufferedImage . TYPE_INT_RGB ) ; // why RGB ? } else { // why not device dependent? bImage = null ; } navigate . setScreenSize ( b . width , b . height ) ; }
when component resizes we need a new buffer