Devansh Shah
Devansh Shah

Reputation: 55

JTextPane and UndoManager

I am developing a TextEditor using Java for the sake of learning GUI Programming in Java. I have added undo redo functionalities in my editor as well as have font options. The undo redo functions work well without any issue. They work for text changes and Font changes(Style,Name,Size,Color) My problem is I want to know if the undomanager has undone or redone FontChanges so that I can add appropriate function calls to it. My only requirement is that I want to take certain actions if Font Changes are undone or redone. Please Help

Upvotes: 0

Views: 122

Answers (1)

camickr
camickr

Reputation: 324118

The UndoableEditEvent has that information.

The basic code would be:

AbstractDocument.DefaultDocumentEvent event =   (AbstractDocument.DefaultDocumentEvent)e.getEdit();

if  (event.getType().equals(DocumentEvent.EventType.CHANGE))
{
    //  do something
}

Or maybe you can just use a DocumentListener. The changedUpdate event will be generated when attributes are changed in the Document.

Upvotes: 1

Related Questions