Problem with subgraph undo/redo

I’m having a problem with JGoSubGraph undo / redo

If I create an instance of JGoSubGraph, add it to the document, call undo, then call redo, only the background rectangle comes back, but not the handle or label (or anything else I add to it).

For example…

    JGoSubGraph subGraph = new JGoSubGraph("Hello");
    subGraph.setLocation(new Point(300,300));
    document.addObjectAtTail(subGraph);

    document.undo();
    document.redo();

If I do something similar with JGoArea, it works as expected…

    JGoArea area = new JGoArea();
    area.setLocation(new Point(300,300));
    JGoBasicNode node = new JGoBasicNode("Hello");
    node.setLocation(new Point(305,305));
    area.addObjectAtTail(node);
    document.addObjectAtTail(area);

    document.undo();
    document.redo();

Bringing the area, and the contained node back as expected.

Am I missing something here? I’m using JGo version 5.15.

Perhaps your code snippets here aren’t complete, and I haven’t tried your code yet, but one thing that is obviously missing is wrapping the operations in a transaction…
In general all modifications of any object or of any document should be preceded by a call to startTransaction and be followed by a call to endTransaction.

Thanks for the quick response.

I did try that earlier, but it didn’t help. Also, I didn’t think it was the problem since the JGoArea code worked.

tried…

    JGoUndoManager undoManager = new JGoUndoManager();
    document.setUndoManager(undoManager);

    document.startTransaction();
    JGoSubGraph subGraph = new JGoSubGraph("Hello");
    subGraph.setLocation(new Point(300,300));
    document.addObjectAtTail(subGraph);
    document.endTransaction("Sub Graph Added");

    document.undo();
    document.redo();

I ran the above examples in a sand box without a problem.

Something in my document listener was messing things up.

Thanks Again for your help Walter!