Code example for JTextComponent

Methods: getDocument

0
import javax.swing.undo.UndoManager;
 
public class UndoRedoUtils { 
 
	public static void registerNewUndoManager(JTextComponent jtc) {
		registerNewUndoManager(jtc, jtc.getDocument());
	} 
	public static void registerNewUndoManager(JComponent jtc, Document d) {
		UndoManager undoManager = new UndoManager();
		d.addUndoableEditListener(undoManager);
	    FormUtils.registerUndoRedoActions(jtc, FormUtils.createUndoAction(undoManager, "undo"), FormUtils.createRedoAction(undoManager, "redo"));
	} 
 
}