File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes UndoManager Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "UndoManager Help" Watch "UndoManager Help" New topic

UndoManager Help

Anand Loni
Ranch Hand

Joined: Jan 20, 2006
Posts: 150

I am using undoManager for Textfield. I have Popup menu associated with textfield. When I click undo from poppup menu single character from textfield is undone. How can I undo all characters that I have typed before undo.

Hoping for reply...

~ Anand,
SCJP 1.5, SCWCD 1.5
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

I wanted my code to behave more like some well-known text editors, where when you type "abcd" and then hit undo, all four letters disappear from the screen. The requirements are more complex than that, if you look carefully, but this is what I came up with:This is in a class that extends UndoManager, by the way. There's some constants and instance variables you need in this class:and the ExpandableEdit class is like this:I chopped this out of working code, hopefully I haven't missed out too much and you can get started with this.
Anand Loni
Ranch Hand

Joined: Jan 20, 2006
Posts: 150
Hi Paul,

Thanks a lot...
The code is working fine....
I agree. Here's the link:
subject: UndoManager Help
It's not a secret anymore!