It’s especially useful for adding undo to JTextComponents, because it (the javax.swing.undo package really) supports the concept of merging multiple undoable edits into a single one - so, for example, if the user types 20 chars onto a single line, then activates undo, you can rig it so the 20 individual char insertions are merged into a single “edit”, since they were contiguous, and “undone” at the same time.
In the general, non-text editor case, UndoManager may not be quite as useful, as you often don’t need a “merging edits” feature. Then it just becomes a container for your undo/redo stacks. Also, for some reason I’ve never been inclined enough to dig into, it’s very slow. For a single quick undo or two, the slowness isn’t noticed, but if you hold down Ctrl+Z (for example) to undo lots of previous edits, you can really see it lag, even on fast machines.