Drawing Graphics2D to Picture in guiNode

What I’m trying to do seemed very simple but I just can’t get it working. I have recently been playing with Processing. It’s a wonderful framework for n00bs like me. Through Processing, I got interested in jMonkey. Now I’m trying to combine the two.



Processing have very good 2D drawing capabilities. From the Processing docs, I can get the contents of the canvas like so: (I hope)



public Graphics2D getImage()

{

return ((PGraphicsJava2D)g).g2;

}



I’m trying to draw the contents that are rendered in Processing ontop my 3D scene.



Basically my question is more of a Java question. How do I get the contents of Graphics2D drawn into BufferedImage so I can update the texture in my Picture instance that are attached to guiNode?