• 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

How to write a undo and redo implementation?

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello. I'm on the point of getting some experiences in Java Desktop applications.

But I've got one challenge right now.

I wish  to know how I could add a backward/forward functionality to the app I'm currently building.

So please, is there any java class or any external java source code that I could use to add to my application?


Please any help shall be mostly appreciated.
 
Saloon Keeper
Posts: 10732
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know what you mean by backwards/forwards. Can you give an example?

Are you talking about an "undo" / "re-do" capability?
 
Daniel Graham
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah. That's the name: I meant the undo and redo functionalities..
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
. . . and welcome to the Ranch
 
Daniel Graham
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Campbell...
 
Carey Brown
Saloon Keeper
Posts: 10732
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to be able to capture the "state" of your program, that is any item that might be changed by the user, such as text, lists, colors, selections, database, files, etc..

Some programs allow you to undo and redo several levels deep. To keep things simple only allow one undo and possible redo for now. When you initialize the interface capture it's state in an object. After every change move the state object to a redo object. If the use selects redo, then restore the state from the redo object.
 
Daniel Graham
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, so that's the strategy. I appreciate that.

So how do we go about that?

I just came to know about the "UndoManager" class. Do you think this class can help me undo all textfields, lists, colors, selections, database, files, etc in my app?
 
Marshal
Posts: 28226
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
Yes, absolutely. It works great once you work out how to use it. If you search for java undo tutorial you'll get a whole lot of people who want you to read their tutorial about how to do that, too.
 
Daniel Graham
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright. Copy that.

Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic