If you have an undo history of say 5, you can just use text.remove() and assign the returned value to an array or ArrayList. Then if the user calls redo (ie put that value you pack) you could do...