my dog learned polymorphism*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Memento pattern in swing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Memento pattern in swing" Watch "Memento pattern in swing" New topic
Author

Memento pattern in swing

Vishal Shaw
Ranch Hand

Joined: Aug 09, 2012
Posts: 179
Hi,

Any ideas on how to implement Memento Design Pattern in swing?

Sorry, if I posted in the wrong forum, but I did not find any appropriate forum


Programming is about thinking, NOT coding
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2413
    
  28

You can implement any design pattern using core Java. SInce, you can use core Java in Swing, you can use any design pattern in Swing.

So, you know what's the Memento Design pattern?
Vishal Shaw
Ranch Hand

Joined: Aug 09, 2012
Posts: 179
Jayesh A Lalwani wrote:You can implement any design pattern using core Java. SInce, you can use core Java in Swing, you can use any design pattern in Swing.

So, you know what's the Memento Design pattern?


Yes, Jayesh I know about the Memento Design Pattern. It can be used to rollback a state . For e.g. redo/undo an operation.

But I am unsure about it's implementation, like shall I save all the object's state whenever any minute change occurs? How do I save the state, shall I save the object for the same or maintain a log for the changes?
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2413
    
  28

Wikipedia has a good description
Vishal Shaw
Ranch Hand

Joined: Aug 09, 2012
Posts: 179
Jayesh A Lalwani wrote:Wikipedia has a good description


I have already studied this page. But there's one problem, in real life scenario, we may do upto 'n' no. of undos and redos. But here , it supports only one. Also, with every object I will have to implement this stuff. So, I was thinking about serializing the states in a log for the same and rollback the states from there.

What do you say? Is it a good idea to save the states in a log and work accordingly?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Memento pattern in swing