Add image to JGoLinkLabel

I have the following

JGoImage img = new JGoImage();



I try to add the image to the label


but label.getParent() always returns null even though the label was added to the document. Is this how I should be adding an image to a label in the first place?

If the label isn’t a JGoArea you can’t call addObjectAtHead or addObjectAtTail.
Instead have the MidLabel of the JGoLabeledLink be an instance of a JGoArea, to which you can add both a JGoText and a JGoImage. In fact, you could just use a JGoIconicNode after removing its Port (assuming you don’t want it to have a JGoPort), if it isn’t Selectable.

I have a <SPAN =highlight>JGoLabeledLink to which I am trying to add an icon
to the top middle position.

JGoImage img = new JGoImage();
img.setSize(16, 16);
I see that the icon is added to the left of the link close to the right port of the left node, instead of in the middle. Can you please

Really? It works for me:
if (myView.getSelection().getPrimarySelection() instanceof JGoLabeledLink) {
JGoLabeledLink link = (JGoLabeledLink)myView.getSelection().getPrimarySelection();
JGoImage img = new JGoImage();
img.loadImage(Demo1.class.getResource(“doc.gif”), true);
img.setSize(16, 16);
myView.getDocument().endTransaction(“replaced MidLabel”);
However, the icon is centered on the link, not just above (i.e. at lower Y coordinates) the link. You can modify this by overriding JGoLabeledLink.positionMidLabel to position the label the way you want.