Reputation: 129
I want to add a 'Undo' feature to my application which removes the last entered number into a field. This is what I got so far
private void btnUndo(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
final UndoManager manager = new UndoManager();
if (evt.getActionCommand().equals("Undo")) {
try {
manager.undo();
} catch (CannotUndoException ex) {
ex.printStackTrace();
}
}
}
Any Ideas? (I have no idea if this is right or not)
Thanks
Upvotes: 1
Views: 186
Reputation: 789
See example of UndoManager
http://www.java2s.com/Code/Java/Swing-JFC/Undomanager.htm
Java Docs :-http://docs.oracle.com/javase/6/docs/api/javax/swing/undo/UndoManager.html
Upvotes: 1