public static BufferedImage convertTo ( JComponent comp , BufferedImage storage ) { if ( storage == null ) storage = new BufferedImage ( comp . getWidth ( ) , comp . getHeight ( ) , BufferedImage . TYPE_INT_RGB ) ; Graphics2D g2 = storage . createGraphics ( ) ; comp . paintComponents ( g2 ) ; return storage ; }
Draws the component into a BufferedImage .