Store your states on a stack, linked list or similar. Undo means go back one place on the stack. Redo means go one place forwards. Back from state 0 means throw CantUndoException. Forward from state n means throw CantRedoException. Any changes of state mean lost whatever is ahead of the present point on the stack, probably easiest done by resetting a maxIndex variable.
The alternative is to store each state change as an operation and put the operations into a list. You can the insert an operation in the middle of the list if you so wish.
JTextComponent, the base class for most text controls in Swing, is your friend here.
Each JTextComponent has a Document that can be retrieved using the "getDocument" method. Document has a method "addUndoableEditListener" which allows you to attach UndoableEditListeners. These trigger "undoableEditHappened" events; the event has an UndoableEdit.
I've also been using Java's own undo mechanism for a few months now, and writing support for text components was of course the first to try it on
That one's easy as the document can listen for undoable edits on its own. For other controls (such as JSpinner and JComboBox, I've got those working too) you have to write custom undoable edit classes. Sure, you can use the text document used in JSpinner, but there's one drawback: setText first removes the entire text (one edit), then adds the new text (two edits). So I found out that undoing to the previous value would require two undo actions each time. In the end, I listen to the stateChanged event of the JSpinner, and create a custom undoable edit there based on the old and new values. That class' undo() method sets the old value, the redo() methods sets the new value. Quite easy in fact.