Revision as of 06:56, 4 December 2010 by Han84 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
/**
 * Add the undo and redo functionality for text area or text field.
 * Returned undoManager is used for undo and redo operations.
 * @param compt
 * @return
 */
public static javax.swing.undo.UndoManager guiGetUndoManager(javax.swing.text.JTextComponent compt) {
	final javax.swing.undo.UndoManager undoManager = new javax.swing.undo.UndoManager();
	compt.getDocument().addUndoableEditListener(
			new javax.swing.event.UndoableEditListener() {
				public void undoableEditHappened(javax.swing.event.UndoableEditEvent e) {
					undoManager.addEdit(e.getEdit());
				}
			});
	return undoManager;
}


Back to JavaHowTo

Alumni Liaison

has a message for current ECE438 students.

Sean Hu, ECE PhD 2009