• 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

Allowing "Undo"s in a SWING GUI

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Has anyone ever created a GUI app that allows users to Undo actions? I've never done one, but am working on an app that will likely need such an architecture. The app basically allows the creation of small data items, editing attributes of the items, re-ordering/rearranging of the items, and deletion of the items... those are the types of activities that will need to be Undo-able.

Obviously I'm not expecting any code samples here, as its sort of a big topic, but can anyone clue me in on what the general approach is for creating an Undo architecture? Or are there any good articles on the subject that anyone knows of?

Thanks!
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dave,
I have developed an app like yours few years ago, I used the Command Pattern which is great to handle actions and their undos.

You'll find a brief description here and the basic design here

If you google using command pattern you will find a lot of articles, tutorials etc.

I hope this helps!
Giovanni
 
dave taubler
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Giovanni,

Thanks! And it's good timing, too, since I just finished reading Head First Design Patterns. I'll head off in that direction and see what I come up with.
 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

don't forget that Swing has it's own undo managers that you can take advantage of. In fact, any text component can use them.

You didn't specify if you are building some kind of text editor, but if you are I highly recommend that you check out:

http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#undo

You need to do very little in order to get it up and running.

Cheers, Jared.
 
reply
    Bookmark Topic Watch Topic
  • New Topic