• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Redo/Undo for Stack Program

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, I'm having some difficulty implementing redo/undo functions for a UI Stack Program.

I have a StackModel package that has PopEdit and PushEdit that extends an abstract ADT StackEdit that creates an ArrayStack.
In my main class, I have methods undoMenuItemActionPerformed and redoMenuItemActionPerformed which once the user clicks on each is supposed to redo/undo the last pop or push.
I've created an undoManager and call it on it whenever the pop or push functions are performed:

However, it is not undoing or redoing anything at all.

Here is my redo method and undo is similar but uses undoManager.undo() instead.


What is happening is undoManager for some reason is not redoing the last action and the program continues on and prints out "Redo Finished," etc...
Any help would be appreciated or other ways to go about the problem?
Thank you!
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Too difficult for this forum: moving.

Please explain exactly what the logic (or algorithm) behind undoing and redoing is.
 
natsumi jay
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a separate stack called edit that contains a record of the Pop and Push that the user has done.
Then I use the UndoManager API to add the stack to its manager.
After this, I'll call on the UndoManager Redo() and Undo() methods, however it doesn't work when I use it with the stack functions.
I've tested it before with a normal text box and the user inputs text.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You say your edit's redo() method isn't doing what you expected, but you haven't shown us that method, nor have you shown us how you create the edit. It would be helpful to see that code.
reply
    Bookmark Topic Watch Topic
  • New Topic