List of usage examples for javax.swing.text Document removeUndoableEditListener
public void removeUndoableEditListener(UndoableEditListener listener);
From source file:com.kstenschke.copypastestack.ToolWindow.java
/** * Add undoManager to clip pane//from w ww . j a v a2 s. c o m */ private void initInlineEditor() { Document document = this.form.textPanePreview.getDocument(); if (this.undoManager != null) { document.removeUndoableEditListener(this.undoManager); } this.undoManager = new UndoManager(); document.addUndoableEditListener(this.undoManager); final ToolWindow toolWindowFin = this; InputMap inputMap = this.form.textPanePreview.getInputMap(); // CTRL + Z = undo ( + Z on Mac OS) inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_Z, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (toolWindowFin.undoManager.canUndo()) { toolWindowFin.undoManager.undo(); } } }); // CTRL + SHIFT + Z = redo ( + SHIFT + Z on Mac OS) inputMap.put( KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.SHIFT_DOWN_MASK | Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (toolWindowFin.undoManager.canRedo()) { toolWindowFin.undoManager.redo(); } } }); }