Prevent Undo/Redo

Discussion in 'Java' started by Jason Cavett, Jun 14, 2007.

  1. Jason Cavett

    Jason Cavett Guest

    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!
     
    Jason Cavett, Jun 14, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andreas Wachhold

    Undo/Redo Java?

    Andreas Wachhold, May 4, 2004, in forum: Java
    Replies:
    2
    Views:
    4,938
    Mykola Rabchevskiy
    May 4, 2004
  2. black

    undo and redo

    black, Dec 23, 2003, in forum: Python
    Replies:
    0
    Views:
    357
    black
    Dec 23, 2003
  3. black

    undo and redo ?

    black, Jan 2, 2004, in forum: Python
    Replies:
    1
    Views:
    362
    Diez B. Roggisch
    Jan 2, 2004
  4. John Benson

    undo/redo, windows clipboard

    John Benson, Jan 2, 2004, in forum: Python
    Replies:
    0
    Views:
    352
    John Benson
    Jan 2, 2004
  5. Robert Brewer

    RE: undo and redo ?

    Robert Brewer, Jan 2, 2004, in forum: Python
    Replies:
    0
    Views:
    361
    Robert Brewer
    Jan 2, 2004
Loading...

Share This Page