Narayanan S
Narayanan S

Reputation: 163

Redo/undo option for an action in swing

I am doing barchart demo in that I want the functionality of doing redo/undo for an event or an action.Can anybody provide me some code snippets which will be greatly appreciated.When i click undo the previous barchart has to be displayed and the vice versa for redo action.Thanks in advance

Upvotes: 0

Views: 3696

Answers (2)

user949300
user949300

Reputation: 15729

One generally implements Undo/Redo by implementing a Command Pattern. For example, see Wikiedia or this example or Google it yourself. Your application usually stores the previously executed Commands, either just the last one (one one level of undo) or using a Stack (for multiple levels)

Upvotes: 0

Adi Mor
Adi Mor

Reputation: 2165

Swing provides Undo and Redo functionality through javax.swing.undo package.

check this example

and this example of Roseindia

Upvotes: 1

Related Questions