I was wondering if there is a way to ignore the text style changes in a JTextPane while using Swing's UndoManager?
I've never tried it, but I would guess you can create a custom UndoManager.
You would need to override the undoableEditHappend(...)
method to ignore an attribute change:
@Override
public void undoableEditHappened(UndoableEditEvent e)
{
// Check for an attribute change
AbstractDocument.DefaultDocumentEvent event =
(AbstractDocument.DefaultDocumentEvent)e.getEdit();
if (event.getType().equals(DocumentEvent.EventType.CHANGE))
return
else
super.undoableEditHappened(e);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With