Java/Swing offscreen rendering (Cobra HTMLPanel -> BufferedImage) Problem: Component doesn't finish
        Posted  
        
            by Alterscape
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Alterscape
        
        
        
        Published on 2010-05-06T18:11:57Z
        Indexed on 
            2010/05/06
            18:18 UTC
        
        
        Read the original article
        Hit count: 332
        
I'm trying to render the contents of a the Java/Swing Cobra HTML renderer to an offscreen BufferedImage, for use elsewhere in my app:
 slideViewPanel.setDocument(document, rendererContext);
 BufferedImage test = new BufferedImage(300,300,BufferedImage.TYPE_INT_RGB);
 Graphics g = test.getGraphics();
 slideViewPanel.paint(g);
The resulting image in g shows a partially rendered page -- sometimes the contents of the HTMLFrame before the new document was set; sometimes a half-rendered version of the new document. I gather this is because Cobra's setDocument method just schedules the document for re-rendering, but I'm stepping through in the debugger and I don't see a second thread to do re-rendering. Anyone have any insight into what might be happening here?
© Stack Overflow or respective owner