midLabel positioning

I have subclassed JGoLabeledLink and am assiging an instance of JGoLinkLabel as the link’s midLabel.

When I first create the link and add it to the document, the text in the midlabel always appears at the view’s origin (upper left corner) regardless of where the link is drawn. If I subsequently move the nodes containing the link’s to or from ports, the midLabel snaps to the correct position on the link and behaves correctly forever after. Just the initial creation gives the bad placement.

I’m guessing that this might have something to do with the fact that my JGoLabeledLink subclass sets its own to and from ports after it has been added to the document.

The order of events is:

  1. Create JGoLabeledLink subclass object.
  2. Add JGoLabeledLink to JGoDocument.
  3. Call method on JGoLabeledLink subclass object to force it to set its to and from ports.
  4. Set the JGoLinkLabel text.

I have tried calling positionLabels() after I set the label text, but this doesn’t fix the problem. Any other suggestions?


Nevermind, I moved where I was calling positionLabels() from and now it is working.