Pregunta

Let's say you have a JEditorPane with which you have registered both an UndoableEditListener and a DocumentListener. When you change the underlying document's contents by typing in the editor pane, what is the order in which the events are fired?

In addition, I assume that, in the interest of efficiency, calling either of these methods:

  • UndoableEdit.undo()
  • UndoableEdit.redo()

...will not trigger a new UndoableEdit event, but will still trigger a new DocumentEvent. Can anyone confirm whether this is indeed the case?

¿Fue útil?

Solución

After trying what camickr suggested, it seems that this is the order of events:

  1. When typing in the editor pane (including cutting, copying and pasting) or changing the document font/style, the document will fire a DocumentEvent before it fires an UndoableEditEvent.

  2. When calling UndoableEdit.undo() or UndoableEdit.redo(), only a corresponding DocumentEvent will be fired.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top