JTextArea setText() & UndoManager
问题 I'm using an UndoManager to capture changes in my JTextArea . The method setText() however deletes everything and then pastes the text. When I undo I firstly see an empty area and then it would show which text it had before. How to reproduce: Run the following code Click the setText() button Press CTRL+Z to undo (you'll see an empty textarea!) Press CTRL+Z to undo (you'll see the actual previous text) I want to skip 3). import javax.swing.AbstractAction; import javax.swing.JFrame; import