Prevent Undo/Redo

J

Jason Cavett

Hello,

I am adding Undo/Redo to JTextFields in the GUI portion of my
application. It's relatively simple to do as in this case...

nameTextField.getDocument().addUndoableEditListener(project.getUndoManager());

Every project has an UndoManager. When I open up a new property
window, I add the UndoManager as a listener to the documents of
various text fields. This works well.

The problem I am having is twofold (although I believe its related to
the same issue).

1. Items are added to the UndoManager whenever ANY change is made to
the text field. Is there any way to prevent this from happening when
I don't want it to happen? My reasoning for this is I populate the
text fields AFTER the UndoEditListener has been added to the text
field, so, because of this, the UndoManager automatically starts off
with edits on the stack.

2. I can potentially have multiple views to the same object. If I
edit one field, it should also update in the other view. The problem
is that this really seems to mess up the UndoManager. Again, I think
this is related to the issue above, but I am really not sure where to
begin to fix something like this.


Any suggestions or help that you can provide would be much
appreciated. Thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top