Painting a JGonode outside a JGoView

For creation of a custom component as substitute to JGoPalette I’d like to know whether there is a way to display a JGoNode outside a JGoView. Instead I’d like to draw it on an extension of JComponent…

I haven’t even tried compiling this code:
public BufferedImage getObjectImage(JGoObject obj, JGoView view) {
Rectangle r = new Rectangle(obj.getBoundingRect());
obj.expandRectByPenWidth®;
BufferedImage img = new BufferedImage(r.width, r.height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = img.createGraphics();
g2.translate(-r.x, -r.y);
view.applyRenderingHints(g2);
obj.paint(g2, view);
g2.dispose();
return img;
}

Testing with a JGoTextNode this gives a NPE:

java.lang.NullPointerException
at java.awt.Font.defaultLineMetrics(Font.java:1594)

I tested it with/without adding the node to the view’s Document and with/without adding the view to a JFrame.

OK, I just tried it, and it worked just fine. But it’s true, as you pointed out, that I already had a working JGoView in my JFrame. (I believe whether the object is part of a JGoDocument or not shouldn’t matter.) I was using JGo 5.15, although I don’t know of any reason that code shouldn’t work with older versions. If you are doing these operations before the JGoView/JFrame is made visible, you could try calling JGoGlobal.setup() first.